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
I would like to mention that your ViewModels should NEVER derive from DependencyObect. NEVER!!!
Hi Krasimir,
I have been trying the model which you have mentioned here but without a luck!
Here's what I did:
Adding Visiblility property for an unbound field -
<igDP:UnboundField Name="gridCustomerId" Label="ID" Binding="{Binding customerid, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding ShowCustomerIDColumn, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
In my View Model, adding a proerty of Visibility type://ToShow CustomerID Column private Visibility showCustomerIDColumn; public Visibility ShowCustomerIDColumn { get { return showCustomerIDColumn; } set { showCustomerIDColumn=value; InvokePropertyChanged("ShowCustomerIDColumn"); } } Then in the command handler using the following code:if(ShowCustomerIDColumn == Visibility.Collapsed) ShowCustomerIDColumn = Visibility.Visible; else ShowCustomerIDColumn = Visibility.Collapsed; InvokePropertyChanged("ShowCustomerIDColumn"); In the constructor of the ViewModel, I'm setting the column to collapsed: ShowCustomerIDColumn = Visibility.Collapsed Please help!
In my View Model, adding a proerty of Visibility type:
//ToShow CustomerID Column private Visibility showCustomerIDColumn; public Visibility ShowCustomerIDColumn { get { return showCustomerIDColumn; } set { showCustomerIDColumn=value; InvokePropertyChanged("ShowCustomerIDColumn"); } }
Then in the command handler using the following code:if(ShowCustomerIDColumn == Visibility.Collapsed) ShowCustomerIDColumn = Visibility.Visible; else ShowCustomerIDColumn = Visibility.Collapsed; InvokePropertyChanged("ShowCustomerIDColumn"); In the constructor of the ViewModel, I'm setting the column to collapsed: ShowCustomerIDColumn = Visibility.Collapsed Please help!
Then in the command handler using the following code:
if(ShowCustomerIDColumn == Visibility.Collapsed) ShowCustomerIDColumn = Visibility.Visible; else ShowCustomerIDColumn = Visibility.Collapsed; InvokePropertyChanged("ShowCustomerIDColumn");
In the constructor of the ViewModel, I'm setting the column to collapsed:
ShowCustomerIDColumn = Visibility.Collapsed
Please help!
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