Reputation: 390
I'm fairly new to MVVM and WPF and have recently started porting an application from WinForms. I'm trying to change a visual state from the ViewModel but can't figure it out.
I have tried all the previously posted solutions but nothing seems to be working. This is what I have:
<UserControl x:Class="WPFApp.View.AddItem"
...
DataContext="{Binding}" helper:StateManager.VisualStateProperty="{Binding Path=VisualStateName}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="OverlayStates">
<VisualStateGroup.Transitions>
...
And in the ViewModel:
private string visualStateName;
public string VisualStateName
{
get
{
return visualStateName;
}
set
{
visualStateName = value;
OnPropertyChanged("VisualStateName");
}
}
When ever I output the value of VisualStateName it is null and if I set it it doesn't change the state of the View. I can't figure out what I'm doing wrong, I've found some notes on other people mistakes but don't seem to have made any of those. Can anyone see what I've done wrong?
I am using the StateManager found here: http://tdanemar.wordpress.com/2009/11/15/using-the-visualstatemanager-with-the-model-view-viewmodel-pattern-in-wpf-or-silverlight/
Upvotes: 0
Views: 62