WinRT 中的数据触发器?
我能够找到 EventTrigger 然而,在 WinRT 参考中,我找不到 DataTrigger。我也无法在应用程序中使用它。
谁能确认 WinRT 中确实缺少 DataTrigger? EventTrigger 是 WinRT 中唯一可用的触发器吗?
I was able to find EventTrigger in the WinRT reference, however, I wasn't able to find DataTrigger. I wasn't able to use it in an application either.
Can anyone confirm that DataTrigger is really missing in WinRT? Is EventTrigger the only trigger available in WinRT?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
WinRT XAML 当前不支持 DataTrigger。
Mike Brown 的附录
DataTrigger API 已替换为 VisualStateManager 与数据触发器类似的 API 由 Blend SDK for Silverlight 提供。由于附加行为模式在 WinRT 中工作,因此可以执行相同的操作。
DataTrigger is not currently supported in WinRT XAML.
Addendum by Mike Brown
The DataTrigger API has been replaced with the VisualStateManager a similar API to Data Triggers was provided by the Blend SDK for Silverlight. Since the Attached Behavior Pattern works in WinRT, it is possible to do the same.
我不知道它何时更改,但我有
datatriggerbehavior
和gotostateaction
组合它们应该解决您的问题...namespace inmanspace imports imports
viewsatemanager eviewatemanager plot on root元素上的位置
I don't know when it changed but i have
DataTriggerBehavior
andGoToStateAction
combining them should solve your problem...namespace imports
ViewSateManager place on root element
这个似乎在 WinRT 中实现触发器的项目怎么样: http://winrttriggers.codeplex.com/
What about this project that seems implement triggers in WinRT : http://winrttriggers.codeplex.com/
我实施了一种可能适合您的替代解决方法。步骤:
它不像 DataTrigger 那样干净,但也没有差太多,而且效果很好(至少对我来说)。
XAML 中的声明(DataContext 已设置为视图模型对象):
触发故事板更改状态的示例 DependencyProperty:
I implemented an alternate workaround that may work for you. Steps:
It's not as clean as a DataTrigger, but it's not too much worse and it works well (for me at least).
Declaration in XAML (DataContext is already set to a viewmodel object):
Example DependencyProperty that triggers storyboards to change state:
您可以使用Visualstate而不是对象。Windows8中的触发者是代码
you can use VisualState instead of object.Triggers in Windows 8 Here is the code