简体   繁体   English

将数据网格从 ObservableCollection 绑定到 ObservableCollection

[英]Bind datagrid to an ObservableCollection from an ObservableCollection

I looked on the net to find the answer, but didn't found exactly what I am looking for.我在网上寻找答案,但没有找到我正在寻找的内容。 This question helped me a lot WPF DataGrid: Binding a Collection Property to Column这个问题对我帮助很大WPF DataGrid: Binding a Collection Property to Column

But I am looking to show the "Name" of the personne and the multiple Smartphones she get.但我希望显示人员的“姓名”和她获得的多部智能手机。

Person's Name1

  Smartphone1  manufacturer    other details
  Smartphone2  manufacturer    other details
Person's Name2

  Smartphone1  manufacturer    other details
  Smartphone2  manufacturer    other details

How could I modify in this post to get the right solution?我该如何修改这篇文章以获得正确的解决方案?

如果您编写的内容是您希望其格式化的方式,而不仅仅是数据结构,那么请查看如何:对 DataGrid 控件中的数据进行分组、排序和过滤

Although it's technically possible to embed one grid inside a cell of another, this type of user interface gets messy very fast.尽管在技术上可以将一个网格嵌入另一个单元格中,但这种类型的用户界面很快就会变得混乱。

I'd suggest using a TreeView control instead - ideal for this type of nested data, and using data templates you can design different UI layouts for Person and Phone elements.我建议改用 TreeView 控件 - 非常适合这种类型的嵌套数据,并且使用数据模板您可以为 Person 和 Phone 元素设计不同的 UI 布局。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM