开发者

how to get header controls in data bound TreeView

I have TreeView with hierarchical data binding. I want to get TreeViewItem.Header controls not my MVVM. I can get TreeViewItem using TreeView.ItemContainerGenerator.ContainerFromIndex() method... but how to get TreeViewItem.Header ?

开发者_如何学C

Regards, Marcin


It is very simple:

var item = TreeView.ItemContainerGenerator.ContainerFromIndex(...);
var header = ((TreeViewItem)item).Header;

However it may not be a good idea: Generally any code that requires access to the header control itself (as opposed to the model) is poorly written and should be rewritten to use data binding instead.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜