Binding VisualState to the ViewModel in Universal

2019-09-04 01:17发布

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条回答
做自己的国王
2楼-- · 2019-09-04 01:27

"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!).

查看更多
登录 后发表回答