在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