如何指定动画目标? [英] How to specify a target for animation?

查看:16
本文介绍了如何指定动画目标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在阅读此问题之前,请请参阅这个

Before you read this question, please see this

现在我在用户控件资源中定义了情节提要,它在 ViewModel 中定义的事件上被触发:

Now I have the storyboard defined in the user control resources and it gets triggered it on an event that is defined in ViewModel:

<UserControl.Resources>
    <Storyboard x:Key="Storyboard2">
        <DoubleAnimation Storyboard.TargetName="Btn_Import" Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:2"/>
        <DoubleAnimation Storyboard.TargetName="Studio" Storyboard.TargetProperty="Opacity" From="0" To="{Binding StudioOpacityValue}" Duration="0:0:2"/>

        <DoubleAnimation Storyboard.TargetName="StudioTranslateLeftToRight" Storyboard.TargetProperty="X" By="{Binding StudioStartingPointWidth}"  Duration="0:0:2">
            <DoubleAnimation.EasingFunction>
                <CubicEase EasingMode="EaseInOut"/>
            </DoubleAnimation.EasingFunction>
        </DoubleAnimation>

        <DoubleAnimation Storyboard.TargetName="Animation" Storyboard.TargetProperty="Opacity" From="0" To="{Binding AnimationOpacityValue}" Duration="0:0:2"/>
        <DoubleAnimation Storyboard.TargetName="Record" Storyboard.TargetProperty="Opacity" From="0" To="{Binding RecordOpacityValue}" Duration="0:0:2"/>
        <DoubleAnimation Storyboard.TargetName="Info" Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:2"/>
        <DoubleAnimation Storyboard.TargetName="textframe_image" Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:2"/>
        <local:CommandFakeAnimation Command="{Binding Path=MainButtonClickedCommand, Mode=OneWay}" CommandParameter="Hide" Storyboard.TargetProperty="Opacity" Duration="0:0:0"/>
    </Storyboard>
</UserControl.Resources>

然后我有一个触发故事板的事件:

and then I have an event that trigers the storyboard:

<i:Interaction.Triggers>
     <i:EventTrigger EventName="FadeInMainButtonsAfterStudio" SourceObject="{Binding Mode=OneWay}">
        <ei:ControlStoryboardAction Storyboard="{StaticResource Storyboard2}"/>
    </i:EventTrigger>
</i:Interaction.Triggers>

我想应用动画的控件是:

and the control that I want to apply the animation to is:

<Button x:Name ="Studio" Grid.Row="33" Grid.Column="57" Grid.ColumnSpan="36" Grid.RowSpan="36"  IsEnabled="{Binding IsStudioEnabled}" Opacity="{Binding StudioOpacityValue}" Command="{Binding MainButtonClickedCommand}" CommandParameter="Show">
    <Button.Template>
        <ControlTemplate>
            <Grid RenderTransformOrigin="0.5,0.5" x:Name="bg">
                <Image x:Name ="studio_image" Source="{Binding StudioBtnBaseImagePath}"/>
            </Grid>
            <ControlTemplate.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter TargetName="studio_image" Property="Source" Value="{Binding StudioBtnOverImagePath}" />
                    </Trigger>

                <Trigger Property="ButtonBase.IsPressed"  Value ="True">
                    <Setter TargetName="bg" Property="RenderTransform">
                        <Setter.Value>
                            <ScaleTransform ScaleX="0.9" ScaleY="0.9"/>
                        </Setter.Value>
                    </Setter>
                </Trigger>

            </ControlTemplate.Triggers>
        </ControlTemplate>
    </Button.Template>

    <Button.RenderTransform>
        <TransformGroup>
            <TranslateTransform x:Name="StudioTranslateLeftToRight" X="0"/>
        </TransformGroup>
    </Button.RenderTransform>

</Button>

但我收到以下运行时错误:

but I get the following runtime error:

附加信息:未指定目标'MainMenu.DummyAnimations.CommandFakeAnimation'

Additional information: No target was specified for 'MainMenu.DummyAnimations.CommandFakeAnimation'

这可能有什么问题?

推荐答案

正如您在得到的错误中明确描述的那样,您没有为您的自定义动画 local 提供 Storyboard.TargetName:命令假动画

As clearly described in the error you are getting, you have not provided Storyboard.TargetName for your custom Animation local:CommandFakeAnimation

这篇关于如何指定动画目标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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