Skip to content

Commit

Permalink
fix(wasm_imagebrush): Fixed a bug when ImageBrush on shapes was dynam…
Browse files Browse the repository at this point in the history
…ically changing on Wasm: the previous image were not removed from the SVG pattern.
  • Loading branch information
carldebilly committed Jul 15, 2021
1 parent fe2f78a commit 8e64a36
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Uno.UI/UI/Xaml/Media/ImageBrush.wasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@ void OnImageSourceChanged(DependencyObject dependencyobject, DependencyPropertyC

void OnStretchChanged(DependencyObject dependencyobject, DependencyPropertyChangedEventArgs args)
{
SetPreserveAspectRatio();
preserveAspectRatio = SetPreserveAspectRatio();
}

void OnAlignmentChanged(DependencyObject dependencyobject, DependencyPropertyChangedEventArgs args)
{
SetPreserveAspectRatio();
preserveAspectRatio = SetPreserveAspectRatio();
}

void OnTargetLayoutUpdated(object sender, object e)
{
SetPreserveAspectRatio();
preserveAspectRatio = SetPreserveAspectRatio();
}

subscriptionDisposable.Disposable = ImageSource?.Subscribe(OnSourceOpened);
Expand All @@ -120,9 +120,14 @@ void OnSourceOpened(ImageData data)
("height", "100%"),
("preserveAspectRatio", preserveAspectRatio),
("href", _imageUri)

);

// Clear any previous image, if any
foreach(var previousChild in pattern.GetChildren())
{
pattern.RemoveChild(previousChild);
}

pattern.AddChild(image);

if (Stretch == Stretch.None)
Expand Down

0 comments on commit 8e64a36

Please sign in to comment.