Bipin
Bipin

Reputation: 21

How to create columns dynamically in MVVM

i have to create a dialog where columns has to be generated at run time, earlier i was using WPF data grid so generating columns at runtime was not a problem. Now i have to use View Model i need to have properties for whatever fields i want to display in view as columns. the number of columns are not known at design time, its not possible for set binding for the data grid.It will be crazy if i create properties at runtime using reflection, is there any way that i can bind runtime generated fields to a data grid column.

Upvotes: 1

Views: 509

Answers (1)

Michael Brown
Michael Brown

Reputation: 9153

If you're on .NET 4 you can use ExpandoObject. It implements INotifyPropertyChanged for you.

Upvotes: 2

Related Questions