Skip to content

Commit

Permalink
[AnimatedIcon] Fix issue where setting source property would not resi…
Browse files Browse the repository at this point in the history
…ze AnimatedIcon properly (#6676)

* Add test and fix for animated icon not updating when setting source property

* Fix test failing downlevel
  • Loading branch information
marcelwgn authored Feb 28, 2022
1 parent 4aeae13 commit fe17f47
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions dev/AnimatedIcon/APITests/AnimatedIconTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,5 +427,36 @@ void AnimatedIcon_LayoutUpdated(object sender, object e)
layoutUpdatedEvent.Set();
}
}

[TestMethod]
public void ChangingSourcePropertyChangesRenderSize()
{
AnimatedIcon icon = null;
RunOnUIThread.Execute(() =>
{
icon = new AnimatedIcon();
Content = new StackPanel() {
Children = { icon }
};
Content.UpdateLayout();
});

IdleSynchronizer.Wait();

RunOnUIThread.Execute(() =>
{
// Icon height will be zero if the source property is not set.
Verify.IsTrue(Math.Abs(icon.ActualHeight) < 0.1);
icon.Source = new AnimatedChevronDownSmallVisualSource();
});

IdleSynchronizer.Wait();

RunOnUIThread.Execute(() =>
{
// Icon will have a height if the AnimatedIcon also updated the visual tree to rerender.
Verify.IsTrue(Math.Abs(icon.ActualHeight) > 10);
});
}
}
}
1 change: 1 addition & 0 deletions dev/AnimatedIcon/AnimatedIcon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ void AnimatedIcon::OnSourcePropertyChanged(const winrt::DependencyPropertyChange
{
SetRootPanelChildToFallbackIcon();
}
InvalidateMeasure();
}

void AnimatedIcon::UpdateMirrorTransform()
Expand Down

0 comments on commit fe17f47

Please sign in to comment.