由ObservableCollection生成和填充的列

由ObservableCollection生成和填充的列

本文介绍了TreeListView,由ObservableCollection生成和填充的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道(甚至有一个例子)基于WPF的TreeListView,可以通过数据绑定到它的树项目的ObservableCollection来生成其列



例如,数据绑定模型是由表示公司的主管层次结构的Employee实例组成的树。每个员工都附加了一个ObservableCollection of Responsibility实例(属性:ResponsibiltyName,ResponsibleSinceDate)。现在我需要在任何一个数据绑定的Employees中找到每个ResponsibiltyName的一个单独的列,并且列值应该使用ResponsibleSinceDate填充。如果员工没有一定的责任,列值应该留空。



WPF中通常会遇到这样的问题?

解决方案

您可能需要查看以下答案:



这里提出了一个涉及CompositeCollection的解决方案:



这里提出了一个涉及HierarchicalDataTemplate的解决方案:



希望这有帮助!


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?

解决方案

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!

这篇关于TreeListView,由ObservableCollection生成和填充的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 00:34