Exemplo n.º 1
0
 private void GridViewEx_ItemPointerEntered(object sender, ItemPointerEventArgs e)
 {
     if (e.Args.Pointer.PointerDeviceType == PointerDeviceType.Mouse)
     {
         var element = e.Element;
         element.RenderTransformOrigin = CalculateElementRenderTransformOrigin(element);
         Canvas.SetZIndex(element, 2);
         var border     = element.GetFirstDescendantOfType <Border>();
         var textBlock  = border.GetFirstDescendantOfType <TextBlock>();
         var storyboard = new Storyboard();
         {
             var animation = new DoubleAnimation()
             {
                 To       = 1.05,
                 Duration = TimeSpan.FromSeconds(0.15)
             };
             Storyboard.SetTarget(animation, element);
             Storyboard.SetTargetProperty(animation, "(UIElement.RenderTransform).(ScaleTransform.ScaleX)");
             storyboard.Children.Add(animation);
         }
         {
             var animation = new DoubleAnimation()
             {
                 To       = 1.05,
                 Duration = TimeSpan.FromSeconds(0.15)
             };
             Storyboard.SetTarget(animation, element);
             Storyboard.SetTargetProperty(animation, "(UIElement.RenderTransform).(ScaleTransform.ScaleY)");
             storyboard.Children.Add(animation);
         }
         {
             var animation = new DoubleAnimation()
             {
                 To       = border.ActualHeight,
                 Duration = TimeSpan.FromSeconds(0.3)
             };
             Storyboard.SetTarget(animation, textBlock);
             Storyboard.SetTargetProperty(animation, "(UIElement.RenderTransform).(TranslateTransform.Y)");
             storyboard.Children.Add(animation);
         }
         {
             var animation = new ColorAnimation()
             {
                 To       = Colors.Transparent,
                 Duration = TimeSpan.FromSeconds(0.3)
             };
             Storyboard.SetTarget(animation, border);
             Storyboard.SetTargetProperty(animation, "(Border.Background).(SolidColorBrush.Color)");
             storyboard.Children.Add(animation);
         }
         storyboard.Begin();
     }
 }
Exemplo n.º 2
0
 private void GridViewEx_ItemPointerExited(object sender, ItemPointerEventArgs e)
 {
     if (e.Args.Pointer.PointerDeviceType == PointerDeviceType.Mouse)
     {
         var element = e.Element;
         Canvas.SetZIndex(element, 1);
         var border     = element.GetFirstDescendantOfType <Border>();
         var textBlock  = border.GetFirstDescendantOfType <TextBlock>();
         var storyboard = new Storyboard();
         {
             var animation = new DoubleAnimation()
             {
                 To       = 1,
                 Duration = TimeSpan.FromSeconds(0.15)
             };
             Storyboard.SetTarget(animation, element);
             Storyboard.SetTargetProperty(animation, "(UIElement.RenderTransform).(ScaleTransform.ScaleX)");
             storyboard.Children.Add(animation);
         }
         {
             var animation = new DoubleAnimation()
             {
                 To       = 1,
                 Duration = TimeSpan.FromSeconds(0.15)
             };
             Storyboard.SetTarget(animation, element);
             Storyboard.SetTargetProperty(animation, "(UIElement.RenderTransform).(ScaleTransform.ScaleY)");
             storyboard.Children.Add(animation);
         }
         {
             var animation = new ObjectAnimationUsingKeyFrames()
             {
                 EnableDependentAnimation = true
             };
             animation.KeyFrames.Add(new DiscreteObjectKeyFrame()
             {
                 KeyTime = TimeSpan.FromSeconds(0.15),
                 Value   = 0
             });
             Storyboard.SetTarget(animation, element);
             Storyboard.SetTargetProperty(animation, "(Canvas.ZIndex)");
             storyboard.Children.Add(animation);
         }
         {
             var animation = new DoubleAnimation()
             {
                 To       = 0,
                 Duration = TimeSpan.FromSeconds(0.3)
             };
             Storyboard.SetTarget(animation, textBlock);
             Storyboard.SetTargetProperty(animation, "(UIElement.RenderTransform).(TranslateTransform.Y)");
             storyboard.Children.Add(animation);
         }
         if (border != null)
         {
             var animation = new ColorAnimation()
             {
                 To       = Color.FromArgb(128, 128, 128, 128),
                 Duration = TimeSpan.FromSeconds(0.3)
             };
             Storyboard.SetTarget(animation, border);
             Storyboard.SetTargetProperty(animation, "(Border.Background).(SolidColorBrush.Color)");
             storyboard.Children.Add(animation);
         }
         storyboard.Begin();
     }
 }