Skip to content

Commit cd9fb30

Browse files
committed
Update BlendedImage.cs
1 parent 94e351e commit cd9fb30

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

dev/DevWinUI.Controls/Controls/Win2D/BlendedImage.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public object PrimaryImageSource
5050
}
5151

5252
public static readonly DependencyProperty PrimaryImageSourceProperty =
53-
DependencyProperty.Register(nameof(PrimaryImageSource), typeof(object), typeof(BlendedImage), new PropertyMetadata(null));
53+
DependencyProperty.Register(nameof(PrimaryImageSource), typeof(object), typeof(BlendedImage), new PropertyMetadata(null, OnSourceChanged));
5454

5555
public object SecondaryImageSource
5656
{
@@ -59,8 +59,16 @@ public object SecondaryImageSource
5959
}
6060

6161
public static readonly DependencyProperty SecondaryImageSourceProperty =
62-
DependencyProperty.Register(nameof(SecondaryImageSource), typeof(object), typeof(BlendedImage), new PropertyMetadata(null));
62+
DependencyProperty.Register(nameof(SecondaryImageSource), typeof(object), typeof(BlendedImage), new PropertyMetadata(null, OnSourceChanged));
6363

64+
private static void OnSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
65+
{
66+
var ctl = (BlendedImage)d;
67+
if (ctl != null)
68+
{
69+
ctl.RebuildSurfaces();
70+
}
71+
}
6472
public BlendedImage()
6573
{
6674
DefaultStyleKey = typeof(BlendedImage);
@@ -91,7 +99,7 @@ private void OnSizeChanged(object sender, SizeChangedEventArgs e)
9199
}
92100
private async void RebuildSurfaces()
93101
{
94-
if (grid == null || _generator == null)
102+
if (grid == null || _generator == null || PrimaryImageSource == null || SecondaryImageSource == null)
95103
return;
96104

97105
var size = new Vector2(_currentWidth, _currentHeight);

0 commit comments

Comments
 (0)