views:

22

answers:

0

I don't have the column names at compile time. I would be available in an array of strings at runtime. I need to read this array and create columns for wpf datagrid. I have MVVM pattern setup and my View has the DataContext setup to ViewModel.

I am able to use ObservableCollection and make it work, but I have to fix the column number/name in the type . The UI needs to update when changes are made in the ViewModel collection.

The following works buy the columns are hardcoded as properties in "MyRowValues" class. I need to get rid of this hardcoding.

In XAML:

DataGrid Name="dataGrid1" ItemsSource="{Binding Path=AppData}"

In ViewModel:

private ObservableCollectionEx _appData; public ObservableCollectionEx AppData { get { return _appData; } set { if (_appData == value) return; _appData = value; OnPropertyChanged("AppData"); } }

Any help would be highly appreciated.