I am using a presentation model to implement navigation in my app with the treeview control. I have the treeviewitem's IsSelected property bound to my view model via two-way binding. When a node that has children is selected, I want the first child of that node to be selected instead of the one that is clicked. It seems like the treeviewitem doesn't listen to the property changed event when it is setting the IsSelected property on my presentation model. The first child node is selected, but the parent node doesn't unselect. Here is the code from my presentation model.
public bool IsSelected {
get {
return this._isSelected;
}
set {
if(this._isSelected != value) {
this._isSelected = value;
if(this.Nodes.Count > 0) {
this._isSelected = false;
this.Nodes[0].IsSelected = true;
}
this.NotifyPropertyChanged("IsSelected");
}
}
}
And here is the style fro my treeviewitem.
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
</Style>