为什么我的Windows Phone的Silverlight旋转动画工作吗? [英] Why isn't my windows phone silverlight rotation animation working?

查看:108
本文介绍了为什么我的Windows Phone的Silverlight旋转动画工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的XAML得到这个:

I've got this in my XAML:

            <Grid.Resources>
                <Storyboard x:Name="Storyboard_Animation">
                    <DoubleAnimation 
                            Storyboard.TargetName="button_Submit" 
                            Storyboard.TargetProperty="Angle" 
                            From="0" 
                            To="360" 
                            Duration="0:0:1"></DoubleAnimation>
                </Storyboard>
            </Grid.Resources>

我在同一网格按钮:

I have the button in the same Grid:

            <Button Grid.Row="0" Grid.Column="1" Content="Submit" Margin="0" Name="button_Submit" Click="button_Submit_Click">
                <Button.Template>
                    <ControlTemplate>
                        <Image Source="Images/buttonImage.png"></Image>
                    </ControlTemplate>
                </Button.Template>
                <Button.RenderTransform>
                    <RotateTransform></RotateTransform>
                </Button.RenderTransform>
            </Button>

我有这个在我的点击方式:

I have this in my click method:

    private void button_Submit_Click(object sender, RoutedEventArgs e)
    {
        Storyboard_Animation.Begin();
    }

当我点击我的按钮,我得到的错误:
指定对象上无法解析TargetProperty角度。

When I click on my button I get the error: Cannot resolve TargetProperty Angle on specified object.

不过,我不知道我应该用比其他角度。

But, I have no idea what I'm supposed to use other than Angle.

我有这样的另一片code的工作正常:

I have this other piece of code that works fine:

    private void RotateStar()
    {
        button_Submit.RenderTransformOrigin = new Point(0.5, 0.5);
        button_Submit.RenderTransform = new RotateTransform();
        DoubleAnimation da = new DoubleAnimation
        {
            From = 0,
            To = 360,
            Duration = TimeSpan.FromSeconds(0.3)
        };
        Storyboard.SetTarget(da, button_Submit.RenderTransform);
        Storyboard.SetTargetProperty(da, new PropertyPath(RotateTransform.AngleProperty));
        Storyboard sb = new Storyboard();
        sb.Children.Add(da);
        sb.Begin();
    }

我喜欢把故事板在XAML,而不是在code。我需要什么补充在我的XAML版本/修改,以便它的工作方式类似于code版?

I'd like to put the storyboard in the XAML instead of in code. What do I need to add/change in my XAML version so that it works like the code version?

推荐答案

试试这个:

<Grid.Resources>
    <Storyboard x:Name="Storyboard_Animation">
        <DoubleAnimation 
            Storyboard.TargetName="button_Submit" 
            Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)" 
            From="0" 
            To="360" 
            Duration="0:0:1">
        </DoubleAnimation>
    </Storyboard>
</Grid.Resources>

这篇关于为什么我的Windows Phone的Silverlight旋转动画工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆