TreeListView 具有由 ObservableCollection 生成和填充的列
有谁知道(或者甚至有一个示例)基于 WPF 的 TreeListView 可以通过数据绑定到其树项的 ObservableCollection 来生成其列?
例如,数据绑定模型是由代表公司主管层次结构的 Employee 实例组成的树。 每个员工另外还有一个 ObservableCollection of Responsibility 实例(属性:ResponsibiltyName、ResponsibleSinceDate)。 现在,我想要在任何数据绑定员工中找到的每个 ResponsibiltyName 都有一个单独的列,并且该列值应使用 ResponsibleSinceDate 进行填充。 如果员工没有特定的责任,则该栏值应留空。
在 WPF 中通常如何解决这样的问题?
Does anyone known (or even has an example) of a WPF based TreeListView that can generate its colums by databinding to the ObservableCollection of its tree items?
For example the databound model is a tree consisting of Employee instances representing the supervisor hierarchy of a company. Each employee addtionally has a ObservableCollection of Responsibility instances (Properties: ResponsibiltyName, ResponsibleSinceDate). Now I want a separate column for each ResponsibiltyName found in any of the databound Employees and the column value should be populated with the ResponsibleSinceDate. If an Employee does not have a certain Responsibilty the column value shall be left blank.
How would one usually approach such a problem in WPF?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能想看看以下答案: 如何将 WPF DataGrid 绑定到可变数量的列?
这里建议使用 CompositeCollection 的解决方案:http://social.msdn.microsoft.com/forums/en-US/wpf/thread/ a4c5b2de-260c-49d0-b4ff-cca6ee4e8b08/
这里建议使用 HierarchicalDataTemplate 的解决方案:http://blogs.msdn.com/karstenj/archive/2005/11/02/488420.aspx
希望这有帮助!
You may want to take a look at the following answer: How do I bind a WPF DataGrid to a variable number of columns?
Here a solution involving a CompositeCollection is suggested: http://social.msdn.microsoft.com/forums/en-US/wpf/thread/a4c5b2de-260c-49d0-b4ff-cca6ee4e8b08/
Here a solution involving a HierarchicalDataTemplate is suggested: http://blogs.msdn.com/karstenj/archive/2005/11/02/488420.aspx
Hope this helps!