I have WPF treeView which has ControlTemplate which show every node of tr开发者_如何学GoeeView 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.
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.
精彩评论