为什么视觉状态不起作用?

时间:2010-09-15 14:49:21

标签: xaml silverlight-4.0

我正在尝试创建可动画控件,但似乎动画不起作用。 VisualStateManager发生了什么?

<VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="loginStates">
            <VisualState x:Name="ready">
                <Storyboard>
                    <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="loginControls" Storyboard.TargetProperty="(UIElement.Visibility)">
                        <DiscreteObjectKeyFrame KeyTime="00:00:00.0000000">
                            <DiscreteObjectKeyFrame.Value>
                                <Visibility>Collapsed</Visibility>
                            </DiscreteObjectKeyFrame.Value>
                        </DiscreteObjectKeyFrame>
                    </ObjectAnimationUsingKeyFrames>
                </Storyboard>
            </VisualState>
            <VisualState x:Name="done">
                <Storyboard>
                    <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="loginControls" Storyboard.TargetProperty="(UIElement.Visibility)">
                        <DiscreteObjectKeyFrame KeyTime="00:00:00.0000000">
                            <DiscreteObjectKeyFrame.Value>
                                <Visibility>Collapsed</Visibility>
                            </DiscreteObjectKeyFrame.Value>
                        </DiscreteObjectKeyFrame>
                    </ObjectAnimationUsingKeyFrames>
                </Storyboard>
            </VisualState>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
    <StackPanel x:Name="loginControls">
    <TextBlock Text="some text" /> 
    </StackPanel>

1 个答案:

答案 0 :(得分:1)

据我所知,ChildWindow的唯一方法是使用StoryBoard:

ready.StoryBoard.Begin();