Binding VisualState to the ViewModel in Universal Windows 10 Apps

为君一笑 提交于 2019-12-12 05:53:42

问题


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.

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

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


回答1:


"Behavior SDK" can be included by right-clicking on References -> Add Reference -> Universal Windows -> Extensions -> 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!).



来源:https://stackoverflow.com/questions/32488115/binding-visualstate-to-the-viewmodel-in-universal-windows-10-apps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!