开发者

How to get Current object from TreeView

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜