I have a ICollectionView
from a ObservableCollection
,
WorkingSpreadOrderCollevtionView = CollectionViewSource.GetDefaultView(SpreadOrderCollection);
my SpreadOrderCollection
is not empty, as can be seen the SourceCollection
count is 1
But why the CurrentPosition
is -1
, and I think because of this, DataGrid
is not showing anything even I have bind the WorkingSpreadOrderCollevtionView
to its ItemSourcce
.
May I know what is the possible bug here?
==========================================================
Edit: The xaml
binding
is as follow, the DataContext
is pretty sure to be correct as another public
property in the same ViewModel
is bind to the same xaml
correctly.
<DataGrid ItemsSource="{Binding WorkingSpreadOrderCollevtionView}" CanUserAddRows="False" AutoGenerateColumns="True" >
</DataGrid>
In addition, I can see the Columns
autogenerated in the datagrid, but I just cant see the record.
==================================================
Update: I have found the dumb bug. I have called GetDefaultView
twice and thinking two difference copies of the view is created, and thus applied two filters on the "two" copies. The second filter prevented the records from showing in the DataGrid
. What I have done now is to create a new view as per below,
WorkingSpreadOrderCollevtionView = new CollectionViewSource { Source = SpreadOrderCollection }.View;