Binding VisualState to the ViewModel in Universal Windows 10 Apps
Asked Answered
A

1

0

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?

Austriahungary answered 9/9, 2015 at 19:57 Comment(5)
Blend SDK is supported. Make sure you use the one in 8.1.Aggrieved
Which one? There are no results on NuGet or when searching for VS extensions. This is the most recent one online but it is dated 2010 microsoft.com/en-us/download/details.aspx?id=10801Austriahungary
Go to Blend and add a for example, GoToStateAction. Blend will then be added to your project automatically.Aggrieved
Hmm, OK I got it working - I found the 'Behavior SDK' in the references menu and tried it before but it didn't work first time around (crashed Blend) however I tried again and it works now (takes a while to load up the behaviors). Also the Behavior<T> base class was missing which made me think that it hadn't properly imported - I had to implement a behavior from DependencyObject, IBehavior from scratch but it works now.Austriahungary
Yeah there's no behavior base class anymore, you will have to use that Interface instead.Aggrieved
A
0

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

Austriahungary answered 10/9, 2015 at 13:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.