在mypage.xaml中我检索了ObservableCollection(Of MyObject)
。 为了填充(几乎全部)我的数据网格的列MyDataGrid
自动予放置的结合编程这样将数据网格绑定到总和
Class myPage
Private _context As New MyData
Private Sub Page_Loaded(sender As Object, e As RoutedEventArgs)
_context.MySubObject.Load
dataGrid.ItemsSource = _context.MySubObject.Local
End Sub
End Class
和我结合的MyDataGrid
2列的MySubObject
2个性能这样
<DataGridTextColumn Header="ID" Binding="{Binding Id}"/>
<DataGridTextColumn Header="Name" Binding="{Binding Name}"/>
这工作正常。 现在,我想绑定第3列。我的问题是,MySubOject
的第3个属性是AnotherObject
的ObservableCollection。我想显示的AnotherObject
对象的数量为所显示,像每个MySubObject
:
ID | Name | NumberofAnotherObjects
----------------------------------
1 | abc | 42
2 | def | 56
3 | xyz | 592
我的想法是删除现有的绑定和创建三个LINQ查询。但我不知道如何在LINQ中动态构建这个总和。你能给我一个提示吗?
谢谢!
所以,它是总结或计数?如果计数:只需将列绑定到集合Count属性''{Binding AnotherObjectsCollection.Count}“' – ASh
这正是我所期待的。谢谢 – bluefox