StopStoryboard显示动画警告

时间:2014-11-25 10:57:49

标签: xaml storyboard wpf-controls

我在网格单元的datatemplate中定义了两个动画。

    <DataTemplate.Resources>
        <Storyboard x:Key="ShowMenuStory">
            <BooleanAnimationUsingKeyFrames Storyboard.TargetName="PART_Menu" Storyboard.TargetProperty="IsOpen">
                <!-- in two seconds the popup is opened -->
                <DiscreteBooleanKeyFrame Value="True" KeyTime="0:0:2.0" />
            </BooleanAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="HideMenuStory">
            <BooleanAnimationUsingKeyFrames Storyboard.TargetName="PART_Menu" Storyboard.TargetProperty="IsOpen">
                <!-- immediately poup is closed -->
                <DiscreteBooleanKeyFrame Value="False" KeyTime="0:0:0.1" />
            </BooleanAnimationUsingKeyFrames>
        </Storyboard>
    </DataTemplate.Resources>

在DataTemplate.Triggers中尝试管理我的故事板:

        <DataTemplate.Triggers>
        <DataTrigger Binding="{Binding IsFocused, ElementName=PART_Editor}" Value="True">
            <DataTrigger.EnterActions>
                <StopStoryboard BeginStoryboardName="HideStory" />
                <BeginStoryboard Name="ShowStory" Storyboard="{StaticResource ShowMenuStory}" />
            </DataTrigger.EnterActions>
            <DataTrigger.ExitActions>
                <StopStoryboard BeginStoryboardName="ShowStory" />
                <BeginStoryboard Name="HideStory" Storyboard="{StaticResource HideMenuStory}" />
            </DataTrigger.ExitActions>
        </DataTrigger>
    </DataTemplate.Triggers>

问题在于,当我聚焦细胞时,首先尝试停止尚未执行的动画(HideStory)。这会产生以下警告:

  

System.Windows.Media.Animation警告:6:无法执行操作,因为指定的Storyboard从未应用于此对象以进行交互式控制。行动=“删除”; ...

你知道我怎么能在xaml中避免这个警告? 感谢

0 个答案:

没有答案