Windows Phone 8.1 弹力球

network | | 访问(38)
<Page.Resources>
    <Storyboard RepeatBehavior="Forever" x:Name="Bounce">
        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ball" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.X)">
            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
            <SplineDoubleKeyFrame KeyTime="00:00:04" Value="297"/>
            <SplineDoubleKeyFrame KeyTime="00:00:06" Value="320"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ball" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.Y)">
            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
            <SplineDoubleKeyFrame KeyTime="00:00:02" Value="-206">
                <SplineDoubleKeyFrame.KeySpline>
                    <KeySpline ControlPoint1="0,1" ControlPoint2="1,1"/>
                </SplineDoubleKeyFrame.KeySpline>
            </SplineDoubleKeyFrame>
            <SplineDoubleKeyFrame KeyTime="00:00:04" Value="0">
                <SplineDoubleKeyFrame.KeySpline>
                    <KeySpline ControlPoint1="1,0" ControlPoint2="1,1"/>
                </SplineDoubleKeyFrame.KeySpline>
            </SplineDoubleKeyFrame>
            <SplineDoubleKeyFrame KeyTime="00:00:05" Value="-20">
                <SplineDoubleKeyFrame.KeySpline>
                    <KeySpline ControlPoint1="0,1" ControlPoint2="1,1"/>
                </SplineDoubleKeyFrame.KeySpline>
            </SplineDoubleKeyFrame>
            <SplineDoubleKeyFrame KeyTime="00:00:06" Value="0">
                <SplineDoubleKeyFrame.KeySpline>
                    <KeySpline ControlPoint1="1,0" ControlPoint2="1,1"/>
                </SplineDoubleKeyFrame.KeySpline>
            </SplineDoubleKeyFrame>
        </DoubleAnimationUsingKeyFrames>
    </Storyboard>
</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,35,0,28">
        <TextBlock Text="我的应用程序" FontSize="20"  />
        <TextBlock Text="BouncingBall" FontSize="60" />
    </StackPanel>

    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <Ellipse Height="85" HorizontalAlignment="Left" Margin="71,0,0,151" VerticalAlignment="Bottom" Width="93" Fill="#FFF40B0B" Stroke="#FF000000" x:Name="ball" RenderTransformOrigin="0.5,0.5">
            <Ellipse.RenderTransform>
                <TransformGroup>
                    <TranslateTransform/>
                </TransformGroup>
            </Ellipse.RenderTransform>
        </Ellipse>
    </Grid>
</Grid>
public sealed partial class MainPage: Page {
    public MainPage() {
        this.InitializeComponent();
        //开始运行Storyboard
        Bounce.Begin();
    }

    protected override void OnNavigatedTo(NavigationEventArgs e) {}
}