diff --git a/dev/AnimatedIcon/APITests/AnimatedIconTests.cs b/dev/AnimatedIcon/APITests/AnimatedIconTests.cs index 9a079a9efe..3bdc626cfa 100644 --- a/dev/AnimatedIcon/APITests/AnimatedIconTests.cs +++ b/dev/AnimatedIcon/APITests/AnimatedIconTests.cs @@ -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); + }); + } } } diff --git a/dev/AnimatedIcon/AnimatedIcon.cpp b/dev/AnimatedIcon/AnimatedIcon.cpp index 960e56b286..4fcf6a02c3 100644 --- a/dev/AnimatedIcon/AnimatedIcon.cpp +++ b/dev/AnimatedIcon/AnimatedIcon.cpp @@ -476,6 +476,7 @@ void AnimatedIcon::OnSourcePropertyChanged(const winrt::DependencyPropertyChange { SetRootPanelChildToFallbackIcon(); } + InvalidateMeasure(); } void AnimatedIcon::UpdateMirrorTransform()