Should datagrid and dataform bind to a PagedCollectionView or an ObservableCollection
If I bind a datagrid and a dataform to the same ItemsSource I assumed that as I select different rows in the datagrid, the selected item would be displayed in the dataform.
It appears this only true if the data source is a PagedCollectionView and not an ObservableCollection? 开发者_Python百科 Is that correct?
ICollectionView
exposes members to handle a selected item and for moving between items. An ObservableCollection
is just a generic list with the added ability to throw an event on change. The DataGrid relies on the SelectedItem functionality of a ICollectionView
to know what the DataGrid has selected.
Note that the DataGrid always uses an ICollectionView
to represent its Items. If you provided an ICollectionView
as the ItemsSource it will use that object but if you provide any other IEnumerable
it will wrap it in its own internal ICollectionView
精彩评论