Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
60
Programmatically hiding TemplateColumn in xamGrid
posted

What is the best approach to programmatically change the visibility (hidden or visible) on TemplateColumns? I tried converters, but apparently since column are not part of the visual data tree, that approach won't work. Is there a work around?

Thank you!

Parents
No Data
Reply
  • 34850
    Suggested Answer
    Offline posted

    Hello Andrew,

    Thank you for your post!

    There are a couple of ways that you can programmatically change the visibility of a TemplateColumn in your XamGrid.

    One option is to start at the XamGrid level, and work your way through the Columns collection of your grid to find the template column you are looking for. Then, you can set the Visibility property on that column in code.

    Since you mentioned a converter, it seems you are looking to bind the visibility though. So, another option is to have a property in your ViewModel that can determine whether or not the column should be visible. Then, if you have a reference to your ViewModel in your XAML, you can bind to it as a source, and then set the Path as your property name. If this property is of type bool, for instance, then you can use your converter to catch when that property changes, and return the corresponding Visibility value.

    I have attached a sample project to demonstrate both of the above procedures. I hope this helps you.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer
    Infragistics Inc.
    www.infragistics.com/support

    XamGridVisibilityCase.zip
Children
No Data