Datagrid {NewItem Placeholder} in collectionview

Jun 16, 2009 at 3: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

Coordinator
Jun 16, 2009 at 10:10 PM

 

Hi khendriks,

<font size="2">

datagrid.ItemsSource =

</font>

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.

 

Thanks,

Keerthi

 

Sep 3, 2009 at 12:18 AM

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

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