将 DataGrid 追加到 DataGrids RowDetailsTemplate 内部
这似乎已绑定,但详细信息网格中的行为空。有什么东西关闭/丢失了吗?
我还尝试过 {Binding SubCustomers}
SubCustomers 是父对象上的列表。
我可以通过这种方式绑定到单个字段,例如名字等。只是不是子集合。
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<DataGrid AutoGenerateColumns="True" ItemsSource="{Binding Source=SubCustomers}" />
</DataTemplate>
</DataGrid.RowDetailsTemplate>
this appears to bind, but rows in Details Grid are empty. Something is off/missing?
I've also tried {Binding SubCustomers}
SubCustomers is a List on parent object.
I am able to bind this way to single Fields such as FirstName etc.. just not the subcollection..
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<DataGrid AutoGenerateColumns="True" ItemsSource="{Binding Source=SubCustomers}" />
</DataTemplate>
</DataGrid.RowDetailsTemplate>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是您试图绑定到父级的 DataContext 上的属性,而不是该特定行上的属性。因此,
RowDetails
的DataContext
是行项,为了获取父项的属性,您需要使用RelativeSource
绑定。如果您绑定到父级的 DataContext,则可以“点向下”到您真正关心的属性:The problem is that you are trying to bind to a property on the
DataContext
of the parent, not on that particular row. So, theDataContext
of theRowDetails
is the row item, and in order to get the parent's property, you need to useRelativeSource
bindings. If you bind to theDataContext
of the parent, you can then "dot-down" to the property you actually care about: