WPF - 显示某些内容的复杂方式
我有一个需要以特殊方式显示的对象:
public class Foo
{
public String GroupName { get; set; }
public String FooName { get; set; }
public ObservableCollection<Bar> Bars { get; set; }
public Boolean IsSpecial { get; set; }
}
我需要显示如下:
|----------------------------------------------------------|
| GROUP NAME \/|
|----------------------------------------------------------|
Normal Name A B C Special Name X
------------------------ ------------------------
NormalFoo1 O O O SpecialFoo1 O
NormalFoo2 O O O
NormalFoo3 O O O
基本上,我知道如何使用分组来创建列表框(这样我可以分组),但我不知道如何拆分将该列表放入正常/特殊每组中,如图所示。复选框的启用取决于 Bar 是否在集合中。
不知道从哪里开始。
I have an Object I need to display in a special fashion:
public class Foo
{
public String GroupName { get; set; }
public String FooName { get; set; }
public ObservableCollection<Bar> Bars { get; set; }
public Boolean IsSpecial { get; set; }
}
I need the display to look like so:
|----------------------------------------------------------|
| GROUP NAME \/|
|----------------------------------------------------------|
Normal Name A B C Special Name X
------------------------ ------------------------
NormalFoo1 O O O SpecialFoo1 O
NormalFoo2 O O O
NormalFoo3 O O O
Basically, I know how to do a ListBox with a Grouping (so I can group), but I don't know how to split that list into Normal/Special PER GROUP like it's shown. The checkboxes are enabled depending on if a Bar is in the collection or not.
No idea where to start from here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ListBox
无法根据IsSpecial
属性将Foo
实例列表拆分为两个集合,您需要必须自己做这件事。这里的“标准”方法是使用 MVVM 模式,在“特殊”Foo 实例和非特殊实例之一上创建两个 ViewModel,然后将每个视图绑定到您的视图。
A
ListBox
isn't going to be able to split the list ofFoo
instances into two sets based on theIsSpecial
property, you are going to have to do this yourself.The 'standard' approach here would be to use the MVVM pattern, creating two ViewModels, on of 'special' Foo instances, one of non-special instances, then bind each to your View.