Datagrid {NewItem Placeholder} in collectionview

Jun 16, 2009 at 2:37 PM

By default the datagrid creates a {NewItem Placeholder} wich I want.

But if I bind another control to the same Observable collection I get that holder also And I can not get rid of it.

Does anyone know a solution for this problem

Jun 16, 2009 at 9:10 PM


Hi khendriks,

<font size="2">

datagrid.ItemsSource =


new ObservableCollection();

listbox.ItemsSource = new CollectionView(datagrid.ItemsSource);

With the above piece of code, you are binding to the same ObservableCOllection but creating different CollectionViews. The second CollectionView will not show NewItemPlaceHolder by default. Hope this works for you.





Sep 2, 2009 at 11:18 PM

If you use a DataTable object, you can filter the rows with linq and verify if the primary key is null

view = from row in dt.AsEnumerable() where !string.IsNullOrEmpty(row.Field<string>("key")) select row; dg.ItemsSource = view.AsDataView();