Hi,
I am trying to generated GroupColumns dynamically, so would like to know if there is any way that I can bind a list or something to GroupColumns, so that n number of group columns can be created on the fly.
A sample would be highly appreciated. FYI - I would like to achieve this thing only through xaml and no code behind.
Thanks,
Sunil
Hello Khanh,
I have created a sample project for you with the functionality you want. Basically I set the DataContext of the XamGrid when a Button is clicked, and also I defined the ColumnLayout in the handler.
Hope this helps you.
Hi Stefan,
Could you help me in this feature? That is, if I have a button on the Window, when I click the button, it will generate a table like that and sits next to it and so on.
I have modified the code but it failed to do so.
I really want a dynamic XamGrid for my project. It would be great if you can convert the XAML code into C#.
Sincerely,
Khanh
Hello,
As I said in some of my previos posts, all kind of Columns collections are read only and you are not able to bind them, so it seems that the best approach is to use code behind or Interactions. If I think of a better solution, I will let you know.
Thanks for the sample. Isn't there any way that I can bind some sort of collection in the xaml itself, so that N number of GroupColumns will get generated dynamically. i.e.
<ig:GroupColumn Key="{Binding MyCollection}">
Or is there any way I can leverage the indexer binding. Because the sample you have attached, it's not exactly a code behind but ultimately we are doing the same thing.
skataria
There are two ways to add GroupColumns. The first one is to define them in XAML and the second one is in the Loaded event e.g. of the XamGrid. Since you want to create them dynamically and you don’t want to use code behind, I created a sample project for you where I used Interactions and I handled the Loaded event in the ViewModel, which is the best option for you.