将 VisualStateManager.VisualStateGroups 分离到资源字典中

发布于 2025-01-05 18:56:06 字数 422 浏览 1 评论 0原文

有什么方法可以将 VisualStateManager.VisualStateGroups 分离到 ResourceDictionary 中吗?

基本上我想要类似的东西

<VisualStateManager.VisualStateGroups x:Name="MyVisualGroups">
    <VisualStateGroup x:Name="A" />
    <VisualStateGroup x:Name="B" />
    <VisualStateGroup x:Name="C" />
</VisualStateManager.VisualStateGroups>

,但显然行不通。有什么办法让它发挥作用吗?

Is there any way to separate the VisualStateManager.VisualStateGroups into a ResourceDictionary ?

Basically I want something like

<VisualStateManager.VisualStateGroups x:Name="MyVisualGroups">
    <VisualStateGroup x:Name="A" />
    <VisualStateGroup x:Name="B" />
    <VisualStateGroup x:Name="C" />
</VisualStateManager.VisualStateGroups>

but it obviously doesn't work. Any way to make it work?

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

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

发布评论

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

评论(1

时光匆匆的小流年 2025-01-12 18:56:06

如果您将它们包装在样式对象中,您应该能够完成这项工作。查看我对这个问题的回答这是一个示例,说明如何包装 VSM 内容以重新设置列表框中所选状态的样式。

注意:不过,我不确定这是否适用于一组通用的 VisualStates。不过,它确实适用于整个列表框 ItemContainerStyle 设置。

If you wrap them in a style objct, you should be able to make this work. Check out my answer to this question for an example of how the VSM stuff is wrapped to restyle the selected state in a listbox.

Note : I am not sure if that would work for a set of generic VisualStates, though. It does work for the whole of a listbox ItemContainerStyle settings, though.

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