Skip to content

Commit

Permalink
Fixed a crash with the items list animations
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Mar 2, 2021
1 parent 5f87b23 commit eb0c096
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions Microsoft.Toolkit.Uwp.SampleApp/Shell.SamplePicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,25 +230,29 @@ private void ContainerItem_Loaded(object sender, RoutedEventArgs e)

private void ItemContainer_PointerExited(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
{
var panel = (sender as FrameworkElement).FindDescendant<DropShadowPanel>();
if (panel != null)
if ((sender as FrameworkElement)?.FindDescendant<DropShadowPanel>() is FrameworkElement panel)
{
AnimationBuilder.Create().Opacity(0, duration: TimeSpan.FromMilliseconds(1200)).Start(panel);
AnimationBuilder.Create().Scale(1, duration: TimeSpan.FromMilliseconds(1200)).Start((UIElement)panel.Parent);

if (panel.Parent is UIElement parent)
{
AnimationBuilder.Create().Scale(1, duration: TimeSpan.FromMilliseconds(1200)).Start(parent);
}
}
}

private void ItemContainer_PointerEntered(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
{
if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse &&
(sender as FrameworkElement)?.FindDescendant<DropShadowPanel>() is FrameworkElement panel)
{
var panel = (sender as FrameworkElement).FindDescendant<DropShadowPanel>();
if (panel != null)
{
panel.Visibility = Visibility.Visible;
panel.Visibility = Visibility.Visible;

AnimationBuilder.Create().Opacity(1, duration: TimeSpan.FromMilliseconds(600)).Start(panel);

AnimationBuilder.Create().Opacity(1, duration: TimeSpan.FromMilliseconds(600)).Start(panel);
AnimationBuilder.Create().Scale(1.1, duration: TimeSpan.FromMilliseconds(600)).Start((UIElement)panel.Parent);
if (panel.Parent is UIElement parent)
{
AnimationBuilder.Create().Scale(1.1, duration: TimeSpan.FromMilliseconds(600)).Start(parent);
}
}
}
Expand Down

0 comments on commit eb0c096

Please sign in to comment.