PageRenderTime 41ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/Visual Studio 2008/VBSL3Animation/UsingKeyFrames.xaml

#
XAML | 68 lines | 52 code | 1 blank | 15 comment | 0 complexity | f21af6d71d7c66352e3fc91041a6ffd0 MD5 | raw file
  1. <!--/****************************** Module Header ******************************\
  2. * Module Name: UsingKeyFrames.xaml
  3. * Project: VBSL3Animation
  4. * Copyright (c) Microsoft Corporation.
  5. *
  6. * This module shows how to create KeyFrames based animation in Silverilght
  7. *
  8. * This source is subject to the Microsoft Public License.
  9. * See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
  10. * All other rights reserved.
  11. *
  12. * History:
  13. * * 9/10/2009 03:00 PM Allen Chen Created
  14. \***************************************************************************/-->
  15. <UserControl x:Class="VBSL3Animation.UsingKeyFrames"
  16. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  17. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  18. Width="400" Height="300">
  19. <UserControl.Resources>
  20. <Storyboard x:Name="MyAnimationStoryboard">
  21. <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="path" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
  22. <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
  23. <SplineDoubleKeyFrame KeyTime="00:00:00.8000000" Value="-4" KeySpline="1,0,1,1"/>
  24. <SplineDoubleKeyFrame KeyTime="00:00:01" Value="-5" KeySpline="0,0,0,1"/>
  25. <SplineDoubleKeyFrame KeyTime="00:00:01.2000000" Value="-4" KeySpline="1,0,1,1"/>
  26. </DoubleAnimationUsingKeyFrames>
  27. <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="path" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
  28. <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
  29. <SplineDoubleKeyFrame KeyTime="00:00:00.8000000" Value="167" KeySpline="1,0,1,1"/>
  30. <SplineDoubleKeyFrame KeyTime="00:00:01" Value="109" KeySpline="0,0,0,1"/>
  31. <SplineDoubleKeyFrame KeyTime="00:00:01.2000000" Value="167" KeySpline="1,0,1,1"/>
  32. </DoubleAnimationUsingKeyFrames>
  33. </Storyboard>
  34. </UserControl.Resources>
  35. <Grid x:Name="LayoutRoot" Background="White">
  36. <Grid.RowDefinitions>
  37. <RowDefinition Height="1*"></RowDefinition>
  38. <RowDefinition Height="9*"></RowDefinition>
  39. </Grid.RowDefinitions>
  40. <StackPanel Grid.Row="0">
  41. <Button Content="Please click me to play animation" Click="Button_Click"></Button>
  42. </StackPanel>
  43. <StackPanel x:Name="MyStackPanel" Background="Orange" Grid.Row="1">
  44. <Path x:Name="path" RenderTransformOrigin="0.5,0.5">
  45. <Path.RenderTransform>
  46. <TransformGroup>
  47. <ScaleTransform/>
  48. <SkewTransform/>
  49. <RotateTransform/>
  50. <TranslateTransform/>
  51. </TransformGroup>
  52. </Path.RenderTransform>
  53. <Path.Fill>
  54. <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
  55. <GradientStop Color="#FFF1F7FB" Offset="0"/>
  56. <GradientStop Color="#FF3794E4" Offset="1"/>
  57. </LinearGradientBrush>
  58. </Path.Fill>
  59. <Path.Data>
  60. <!-- Describes an ellipse. -->
  61. <EllipseGeometry x:Name="MyAnimatedEllipseGeometry"
  62. Center="50,50" RadiusX="15" RadiusY="15" />
  63. </Path.Data>
  64. </Path>
  65. </StackPanel>
  66. </Grid>
  67. </UserControl>