如何测试 VisualStateManager 状态?

发布于 2024-12-21 20:13:55 字数 65 浏览 3 评论 0原文

如何检查控件的当前状态? VisualStateManager 允许我从控件本身设置它,但我看不到任何读回它的方法?

How do I check the current states of a control? VisualStateManager allows me to set it from the control itself, but I can't see any way of reading it back?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

惯饮孤独 2024-12-28 20:13:55

如果您有一个组,或者想要查找特定组中的状态,您可以执行以下操作:

    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="Group1">
            <VisualState x:Name="State1">
                <Storyboard>

                </Storyboard>
            </VisualState>
            <VisualState x:Name="State2">
                <Storyboard>

                </Storyboard>
            </VisualState>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>

在您的代码中,您可以执行以下操作:

var state = Group1.CurrentState;
Console.WriteLine(state.Name);

If you have one group, or wants to find the state in a specific group you can do something like :

    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="Group1">
            <VisualState x:Name="State1">
                <Storyboard>

                </Storyboard>
            </VisualState>
            <VisualState x:Name="State2">
                <Storyboard>

                </Storyboard>
            </VisualState>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>

and in your code you can do something like :

var state = Group1.CurrentState;
Console.WriteLine(state.Name);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文