停止以视觉状态开始的故事板

时间:2013-08-18 10:58:52

标签: wpf triggers storyboard datatrigger

我的故事板以州开头:

<VisualStateManager.VisualStateGroups>
    <VisualStateGroup x:Name="MySG">
        <VisualState x:Name="State1">
            <Storyboard>
                <BooleanAnimationUsingKeyFrames Storyboard.TargetName="Btn1" Storyboard.TargetProperty="(UIElement.IsEnabled)">
                    <DiscreteBooleanKeyFrame KeyTime="0" Value="True"/>
                </BooleanAnimationUsingKeyFrames>
            </Storyboard>
        </VisualState>
        <VisualState x:Name="State2">
            <Storyboard>
                <BooleanAnimationUsingKeyFrames Storyboard.TargetName="Btn1" Storyboard.TargetProperty="(UIElement.IsEnabled)">
                    <DiscreteBooleanKeyFrame KeyTime="0" Value="False"/>
                </BooleanAnimationUsingKeyFrames>
            </Storyboard>
        </VisualState>
    </VisualStateGroup>
</VisualStateManager.VisualStateGroups>

我想通过按钮中的触发器停止它:

  <Button x:Name="Btn1"  Height="50" Width="200" Content="My Button">
            <Button.Triggers>
                <DataTrigger Binding="{Binding ElementName=txt1,Path=(Validation.HasError)}" Value="True">
                    <DataTrigger.EnterActions>
                        <StopStoryboard BeginStoryboardName="?"/>
                    </DataTrigger.EnterActions>
                    <DataTrigger.ExitActions>
                        <ResumeStoryboard BeginStoryboardName="?"/>
                    </DataTrigger.ExitActions>
                </DataTrigger>
            </Button.Triggers>
        </Button>

如果我不知道BeginStoryboardName,我该怎么办?

0 个答案:

没有答案