CommonStates不会自动触发

问题描述 投票:0回答:1

我正在尝试使用CommonStates来动画我的用户控件。我尝试了以下方法:

 <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="CommonStates">
            <VisualState x:Name="Normal">
            </VisualState>
            <VisualState x:Name="PointerOver">
                <Storyboard>
                    <ColorAnimationUsingKeyFrames Storyboard.TargetName="circle"
                                                  Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
                                                  EnableDependentAnimation="True">
                        <LinearColorKeyFrame Value="Red"
                                             KeyTime="0:0:0.02" />
                    </ColorAnimationUsingKeyFrames>
                </Storyboard>
            </VisualState>
            <VisualState x:Name="Pressed">
            </VisualState>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
    <Ellipse x:Name="circle"
             Height="280"
             Width="280"
             Fill="Green" />
</Grid>

我可以通过手动调用qazxsw poi来生成更改,但是参考文档应该自动触发commonstates。

知道我做错了吗?

uwp storyboard uwp-xaml visualstatemanager visualstategroup
1个回答
2
投票

一些控件已经定义了视觉状态,并在它们的实现中在它们之间切换,例如UpdateStates(true)Button。在这种情况下,这些状态列在文档Checkbox中。不幸的是like here不是其中之一,所以如果你想要类似的行为,你需要添加事件处理程序并手动使用Grid。您还可以从GoToState创建自定义派生类,以使此行为可重用。

© www.soinside.com 2019 - 2024. All rights reserved.