I've got the following problem:
In my TreeView i added unselect functionality by calling my own deselect()-method when the user clicks the TreeView but not a TreeViewItem. Here is my TreeView method:
public void deselectAll()
{
TreeViewItem item = SelectedItem as TreeViewItem;
if (item != null)
{
this.Focus();
item.IsSelected = false;
}
}
My problem is, that i can't reselect a TreeViewItem after i unselected it. I've read, that focusing the TreeView itself should solve this problem, but it's not. It also doesn't matter if i put the 'Focus()' before or after the 'IsSelected = false'.
Does anyone has an idea why this is not working? Any thoughts would be appreciated.