如何指定动画的目标



在阅读此问题之前,请查看此

现在我在用户控制资源中定义了故事板,它在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>

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

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

我想应用动画的控件是:

<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>

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

附加信息:没有为指定目标'主菜单。Dummy动画。CommandFakeAnimation’

这可能有什么问题?

如您收到的错误中所述,您尚未为自定义动画local:CommandFakeAnimation 提供Storyboard.TargetName

相关内容

  • 没有找到相关文章

最新更新