基于项目文件夹结构的 Wpf Treeview 绑定
我目前有一个文件目录,我想读入我的项目中的程序。 结构。
Project
- Properties
- References
- Manufacturers (want to project this as treeview)
- Honda
- file1
- file2
- Toyota
- file1
- file2
在我的程序中,上面的每个文件都由其自己的业务对象表示。 我希望能够在我的程序中将其显示在我的树视图中。
- Honda
- file1
- file2
- Toyota
- file1
- file2
我只加载这些文件一次,所以我只想读取这些文件一次并将它们绑定到树视图。有没有一种优雅的方法来做到这一点???
谢谢, 凯夫
I currently have a catalog of files I want to read into my program in my Project.
Structure.
Project
- Properties
- References
- Manufacturers (want to project this as treeview)
- Honda
- file1
- file2
- Toyota
- file1
- file2
In my program each file above is represented by its own business object.
I want to be able to in my program have this in my treeview.
- Honda
- file1
- file2
- Toyota
- file1
- file2
I only load these file once so I want to just read these file once and bind them to the tree view. Is there an elegant way to do this???
Thanks,
Kev
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 HierarchicalDataTemplate
您的业务对象可能看起来像这样...
然后,您可以将
TreeView
的DataContext
设置为ObservableCollection
You can make use of a HierarchicalDataTemplate
Your business objects could look something like this...
You would then set the
DataContext
of theTreeView
toObservableCollection<Manufacturer>