tags:

views:

29

answers:

1

I have WPF treeView which has ControlTemplate which show every node of treeView consisting of two elements : Image + Textbox. When I change TextBox treeView element not select. But I want to get Selected class in TextChanged event of TextBox. How can I get class to which current textBox Bound in code behind.

+1  A: 

Try this:

Bind textbox's IsFocused property to treeviewitems's IsSelected property

<TextBox IsFocused = {Binding Path=IsSelected, RelativeSource={RelativeSource AncestorType={x:Type TreeViewItem}}, Mode="OneWayToSource"} />

Else Add a trigger to the textbox such that whenever the IsFocused property is set to true, the corresponding treeviewitem's IsSelected property is also set true.

Veer
interesting idea
Polaris