MadSeb
MadSeb

Reputation: 8254

WPF datagrid binding : add new item

I have the following window in my app:

alt text

The list is declared as : IList < Vendor > _editList; and the datagrid is populated via : dataGridVendors.ItemsSource = _editList;

The "New" button creates a new Vendor and adds the vendor the _editList. Vendor vendor = new Vendor(); _editList.Add(vendor);

Unfortunately.... the new vendor does not show up in the datagrid........any ideas on how to make the new item show up ??

Regards, Sebastian

Upvotes: 3

Views: 1375

Answers (1)

Amry
Amry

Reputation: 4971

Use ObservableCollection:

IList<Vendor> _editList = new ObservableCollection<Vendor>();

The rest of your code should remain the same.

Upvotes: 9

Related Questions