I'm not entirely sure as to why your using a SelectionChanged event here.
You only need to work with the combobox selected item property change and this is easily done with binding.
Here's my rough thinking I hope that it helps. (Note that I've just typed it in without recourse to VS).
In your ViewModel all you need are the following:
private MrMan fieldMrMan;/// best to ensure that this is instanciated.
private List<MrMan> fieldMrMen;/// best to ensure that this is instanciated.
public bool IsGrumpy
{
get{return this.fieldMrMan.IsGrumpy;}
set
{
if(this.fieldMrMan.Name!="MrGrumpy")
this.fieldMrMan.IsGrumpy=value;
}
public MrMan MrManSelected
{
get{return this.fieldMrMan;}
set
{
if(value == this.fieldMrMan)
return;
///Raise property change event here
}
}
public List<MrMan> MrMen
{
get{return fieldMrMen;}
}
Then in your view
<ComboBox x:Name="mrmenName" ItemsSource="{Binding MrMen}" SelectedItem="{Binding MrManSelected}"/>
That copes with the changing of the selection from MrHappy to MrGrumpy.
You would then have a dataModel for your
public class MrMan
{
public MrMan(string name, bool grumpy)
{
this.Name = name;
this.IsGrumpy = grumpy;
}
public string Name{get;set;}
public bool IsGrumpy{get;set;}
}
You obviously already have your MrMan classes instantiated and initialized with data from some data repository anyway.
Thinking about it you may want to override the setting of the IsGrumpy property within the MrMan data model rather than within the ViewModel but that's up to you.