我提出以下问题:
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 .
是否有人想为什么不这样做? 任何想法都会受到赞赏。