开发者

How do I expand treeview node by clicking on section header (Silverlight)

How do I expand t开发者_开发技巧he node by clicking on the item text?

Purpose is to make it easier to expand or close a node, apart from depending on the Expander arrow button.


This seems to work. This toggles the item expanded/collapsed, but you could do item.IsExpanded = true; instead if you like.

TreeViewItem item = (TreeViewItem)treeView.ItemContainerGenerator.ContainerFromItem(treeView.SelectedItem);
item.IsExpanded = !item.IsExpanded;

You can fire this code in the mouse-button-up event handler of your label. If you put it in the mouse-down event handler, the tree view item won't have been selected yet.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜