HI all,
I am using infragistics xamgrid with few predefined textcoumns. I have a button in the same screen when I click on the button I need to hide 2 columns in the xamgrid. I want to do it through it's viewmodel class
Can any one please provide me the resoution for my issue or any existing sample?
Thanks in advance.
Hello,
Thank you for your post. I have been reading through it and I have created a sample application for you that demonstrates how you can hide/show columns in the XamGrid using MVVM pattern. To do that I have used a Command and properties of the ViewModel, bound to the Visibility of the columns.
Please let me know if you need any further assistance on the matter.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
Hi Krasimir,
Thanks for your reply, The resolution you have provided is good. I have one question here, let's assume that I have 50 columns and I need to hide 10 columns then I need to create 10 visibility properties, instead of that can we do like keep column names in list and based on the list can we hide only columns defined in list using any converters like that
Is it possible? if so can you provide me any sample code
Thank you for your reply. I have been looking into it and I can suggest passing the columns collection of the XamGrid as parameter of the Command and in the execute method of the command to loop trough the columns in the collection and if the key of the column is in the list of the columns that should be removed, you can set its Visibility to the appropriate value. I have modified the sample application I have sent you in order to implements this approach.
Please let me know if I can further assist you on the matter.
Thanks for your immediate reply on this, your resoultion is very good, a small correction in my question. I want it to be more generic so I have moved this grid into another xaml view and search button is in another xaml.
In this case can we implement the above solution, if so how can we send the columns collection as command parameter?
Please provide me your suggestion/sample
Thanks in advance
Thank you for your feedback. I have been looking into the scenario that you have described and I can suggest modifying the approach I have suggested with my previous reply. Since the XamGrid is in a view (I assume it is an UserControl), you can bind the CommnadParameter of the Button to that view, using ElementName binding and use a converter, in which you can find the XamGrid and return its Columns collection. I have modified the sample application of my previous reply, in order to implement this approach.