将 VisualState 绑定到通用 Windows 10 应用程序中的 ViewModel [英] Binding VisualState to the ViewModel in Universal Windows 10 Apps

查看:18
本文介绍了将 VisualState 绑定到通用 Windows 10 应用程序中的 ViewModel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经使用自定义 Blend 行为将 ViewModel 上的枚举绑定到 VisualState 的名称与枚举枚举相同的名称.

I used to use a custom Blend behavior to bind an enum on the ViewModel to VisualState's that were named the same as the enum enumerations.

但是,在包含引用然后包含 using 之后,似乎当前不支持 Bahaviors SDK.

However after including references and then including the usings, it seems the Bahaviors SDK is not currently supported.

目前在 Windows 10 通用应用程序中以 MVVM 方式更改 VisualState 的最佳方法是什么?

What is the current best way to change VisualState in a MVVM way in a Windows 10 Universal App?

推荐答案

Behavior SDK"可以通过右键单击 References -> Add Reference -> Universal Windows -> Extensions -> Behavior SDK 来包含.

"Behavior SDK" can be included by right-clicking on References -> Add Reference -> Universal Windows -> Extensions -> Behavior SDK.

某些 API 已更改,因此 Behavior 不可继承(使用 DependencyObject, IBehavior 代替并实现 IBehavior界面).另外 VisualStateUtilities.TryFindNearestStatefulControl 现在是 VisualStateUtilities.FindNearestStatefulControl.当我导入我的旧行为并且即使引用了 Behavior SDK 也无法解析引用时,这让我认为导入没有工作(特别是因为有关于导入 Behavior SDK 的警告,声称它可能不起作用 -查找更多信息的链接已失效,这几乎无法激发信心!).

Some of the APIs have been changed, so Behavior<T> is not there to inherit from (use DependencyObject, IBehavior instead and implement the IBehavior interface). Also VisualStateUtilities.TryFindNearestStatefulControl is now VisualStateUtilities.FindNearestStatefulControl. When I imported my old behaviors and couldn't resolve the references even with the Behavior SDK referenced, it made me think that the imports had not worked (especially since there is a warning about importing the Behavior SDK which claims it might not work - the link to find out more information is dead which hardly inspired confidence!).

这篇关于将 VisualState 绑定到通用 Windows 10 应用程序中的 ViewModel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆