I have both ICollectionView
and ObservableCollection<ItemVM>
(for now) exposed from view model:
public ICollectionView ItemsView
{
get => !IsInDesignMode ? _itemsView :
CollectionViewSource.GetDefaultView(new ObservableCollection<Item>());
set => Set(ref _itemsView, value));
}
public ObservableCollection<Item> Items
{
get => _items;
private set => Set(ref _items, value);
}
and both of them are bound to ItemsSource
of a DataGrid
:
<StackPanel d:DataContext="{d:DesignInstance Type={x:Type vm:ItemsTestVM}}">
<DataGrid Name="DG1" ItemsSource="{Binding Items}"/>
<DataGrid Name="DG2" ItemsSource="{Binding ItemsView}"/>
</StackPanel>
while both display items in runtime, only the DG1 (observable-bound one) display (three dummy) rows in design-time.
Why is that and how can I fix this error?