0

I'm binding to an ienumerable(items) in my MainViewModel to display data. As i've described here before How to change the content in a datagrid or listview using MVVM, all i want to do is display different tables. My first approach was to use the normal datagrid and set the "AutoGenerateColumns" to true, so that the correct columns are displayed. As it turns out, performance was pretty bad so i switched to ListView and GridView, but since there is no "AutoGenerateColumns" available i need to somehow create and change the columns.

So how would you do it?

Community
  • 1
  • 1
xDev23
  • 25
  • 2

1 Answers1

0

Have a look at this question for something that comes close to -- but is not -- auto-generation: WPF GridView with a dynamic definition.

Generally speaking, autogenerating means doing reflection on the ItemsSource, which can get messy since it needs to cover a huge number of possibilities correctly.

Community
  • 1
  • 1
Jon
  • 428,835
  • 81
  • 738
  • 806
  • So i have to write code in the code-behind to get that kind of functionality? I actually know the columns, so i don't need auto generation, i just need to switch the columns depending on certain conditions – xDev23 Apr 05 '11 at 08:24
  • @xDev23: As far as I know, yes. – Jon Apr 05 '11 at 08:30