You cannot modify items in Items collection if you provided it as ItemsSource . You should either add item to your list (with INotifyCollectionChanged implemented or you should initially populated Items property via Add method.
Up vote 0 down vote favorite share g+ share fb share tw.
I have a DataGrid and fill it when window loaded, like this: private void Window_Loaded(object sender, RoutedEventArgs e) { var list = DbService.GetStuffsFull(); dataGrid. ItemsSource = list; } and when I try to add a new row at run-time by this code: Stuff item = new Stuff(); dataGrid.Items. Add(item); I get this error: Operation is not valid while ItemsSource is in use.
Access and modify elements with ItemsControl. ItemsSource instead. How can I add a new row at runtime?
Wpf data-binding datagrid wpfdatagrid link|improve this question edited Jun 12 '11 at 8:34love Computer science1,258218 asked Jun 12 '11 at 8:06Javad_Amiry3,5961621 76% accept rate.
You cannot modify items in Items collection if you provided it as ItemsSource. You should either add item to your list (with INotifyCollectionChanged implemented or you should initially populated Items property via Add method. The error description is pretty clear, isn't it?
Note that in most cases, the best way to get INotifyCollectionChanged is to use `ObservableCollection;. – svick Jun 12 '11 at 9:20.
Try doing something like this: var row = dataGrid.NewRow(); dataGrid.Rows. Add(row); row"column1" = "data1"; row"column2" = "data2"; row"column3" = "data3"; InitializeComponent().
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.