简体   繁体   English

如何使用项目集合绑定Treeview

[英]How to Bind Treeview with collection of items

I have a class : 我有一节课:

Public Class treeModel

    Public Property title As String
    Public Property type As String
    Public Property id As String
    Public Property items As List(Of treeModel) 'Sons

End Class

this class contains metadata about each item and a list of it's sons , How to bind this class to WPF Treeview controller ? 此类包含有关每个项目的元数据及其子列表,如何将此类绑定到WPF Treeview控制器? , and when item selected How can I access it's metadata ? ,当选择项目时如何访问它的元数据?

Thanks for Help. 感谢帮助。

To bind to the nested collection of objects to your treeView you need to define a Hierarchical DataTemplate along with DataTemplate in your view. 要将嵌套的对象集合绑定到treeView,您需要在视图中定义Hierarchical DataTemplate以及DataTemplate If it's something new to you, these links might be helpful to you - 如果这对您来说是新的,这些链接可能对您有所帮助 -

WPF TreeView binding and Binding with treeView or let a search engine do the honours for you - Search for Binding to treeView in WPF WPF TreeView绑定使用treeView绑定或让搜索引擎为您做荣誉 - 在WPF中搜索绑定到treeView

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM