tags:

views:

128

answers:

2

I have a datagrid and want to bind it to a 2 dimensional array and reflect changes in the array to ui automatically (using observable collection for example). However, I am stuck now because datagrid.itemssource = array gives me "'The invocation of the constructor on type 'WpfApplication1.MainWindow' that matches the specified binding constraints threw an exception.' " error. Also I don't have any idea how to update ui automatically? What could be possible solutions?

+1  A: 

Why dont you convert two dimensional array into one dimensional collection? You can create dynamic class(using Dotnet 4.0).

Rakesh Gunijan
+1  A: 

The WPF UI (including the DataGrid) is only updated automatically when the bound object implements INotifyCollectionChanged (for collections) or INotifyPropertyChanged (for single objects). If you want to display a collection of objects and have both the collection and the properties of the contained objects automatically updated, there's little choice aside from having an ObservableCollection (which implements INotifyCollectionChanged) which contains objects that implement INotifyPropertyChanged.

How you would go about creating the objects that conform to these requirements is up to you and the specific requirements/restrictions of your data model.

Alex Paven