views:

900

answers:

1

Hi guys

I'm getting nuts here with this:

ObservableCollection<Employee> list = new ObservableCollection<Employee>();
dgEmployees.ItemsSource = list;

When you debug the list variable, it's empty (list.Count =0), but then I bind it to a DataGrid (WPFToolkit), it shows me a blank row.

In immediate window, for dgEmployees.Items it's showing:

dgEmployees.Items[0]
{NewItemPlaceholder}

and

dgEmployees.Items[0].GetType()
{Name = "NamedObject" FullName = "MS.Internal.NamedObject"}
[System.RuntimeType]: {Name = "NamedObject" FullName = "MS.Internal.NamedObject"}

It seems to happen after I've put this Datagrid into a TabControl, but I'm not sure it has something to do with it.

Does anyone know how to remove this blank row?

+1  A: 

I've got it

on Datagrid XAML, put the attribute:

IsReadOnly="True"
Junior Mayhé
Would be nice if you marked the question as answered, thanks!
Thies