【发布时间】:2014-01-07 20:38:34
【问题描述】:
我有一个 WPF TreeView,它绑定到一个对象列表,其中每个对象都有多个列表。
public List<OwnerClass> OwnerClasses {get; set;}
public class OwnerClass
{
public List<SomeObject> SomeObjects { get; set; }
public List<OtherObject> OtherObjects { get; set; }
}
我正在寻找一种方法将两个列表都显示为父级的子级。
像这样:
> Owner1
|
+ SomeObject 1
+ SomeObject 2
+ SomeObject 3
+ OtherObject 1
+ OtherObject 2
+ OtherObject 3
+ OtherObject 4
> Owner2
|
+ SomeObject 1
+ SomeObject 2
+ SomeObject 3
+ OtherObject 1
+ OtherObject 2
+ OtherObject 3
+ OtherObject 4
我想要树视图功能,但我想要并排的子列表。 (并且每一个都是树视图,因为它们又都有列表。)
这可能吗?
【问题讨论】:
-
创建一个合适的 ViewModel。将您拥有的任何格式的数据转换为可以在
HierarchicalDataTemplate中使用的格式。
标签: c# wpf xaml datatemplate hierarchicaldatatemplate