如何在xaml中进行翻译转换?

时间:2016-04-06 13:44:39

标签: wpf xaml

我有一个我想要水平翻译的按钮,所以我使用这样的故事板:

 <Button>
<Button.Triggers>
                <EventTrigger RoutedEvent="Button.Click">
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="Studio" Storyboard.TargetProperty="RenderTransform.(TranslateTransform.X)" From="0" To="5000" Duration="0:0:2">
                                <DoubleAnimation.EasingFunction>
                                    <CubicEase EasingMode="EaseInOut"/>
                                </DoubleAnimation.EasingFunction>
                            </DoubleAnimation>
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
</Button.Triggers>
 </Button>

但没有任何反应

1 个答案:

答案 0 :(得分:3)

没有任何结果,因为Button TranslateTransform中没有RenderTransform

只需添加一个,然后从DoubleAnimation中删除Storyboard.TargetName

<Button ...>
    <Button.RenderTransform>
        <TranslateTransform/>
    </Button.RenderTransform>
    <Button.Triggers>
        <EventTrigger RoutedEvent="Button.Click">
            <BeginStoryboard>
                <Storyboard>
                    <DoubleAnimation
                        Storyboard.TargetProperty="RenderTransform.X"
                        To="5000" Duration="0:0:2">
                        <DoubleAnimation.EasingFunction>
                            <CubicEase EasingMode="EaseInOut"/>
                        </DoubleAnimation.EasingFunction>
                    </DoubleAnimation>
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
    </Button.Triggers>
</Button>