XAML - 仅从一个源动态创建不同的 GridView

XAML - Dynamic creation of different GridViews from only a Source

我正在尝试使用列表创建一些动态网格视图。

这是我的情况,我有一个包含一些属性的对象列表:名称、描述、组。

我想为每个组类型创建一个 Gridview。

有没有办法 "filter" 源或者可能对源进行分组?

(P.S。抱歉英语不好,我已经尽力了)

我认为您应该在具有此元素列表的 VM 中执行此操作"filter/groups",然后您可以轻松地将这些集合绑定到网格。

public ObservableCollection<YourEntity> get{ return OriginalCollection.Where(x=> x.Group == "TargetGroup")}

我已经解决了我的问题。

我用过:

var result = from act in list
             group act by act.groupname into grp
             orderby grp.Key
             select grp;

并使用 结果 作为 GridView

的来源