GridColumn.IsVisibile binding

Posted by: rcourreges on 12 January 2022, 10:23 am EST

    • Post Options:
    • Link

    Posted 12 January 2022, 10:23 am EST

    I’m just starting out using the WPF FlexGrid to convert from the standard WPF DataGrid and I’m trying to bind the IsVisible property of some GridColumns in a FlexGrid to a property in my view model to control when they are visibile or not.

    IsVisibile is not a DependencyProperty, so I can’t bind to it. GridColumn is not a DependencyObject, so I can’t use an AttachedProperty. Is there some other way that is recommended to dynamically control GridColumn visibility? There are plenty of hacky ways to solve it, but I was hoping a good method already exists.

  • Posted 12 January 2022, 7:59 pm EST

    Hi,

    You can make use of Binding Proxy as shown below.

    ```

    local:FlexGridExtended.BindableSettings

    <local:BindableColumnSettings ColumnName=“Name” DataContext=“{Binding Path=Data, Source={StaticResource proxy}}”

    IsColumnVisible=“{Binding VisibleColA}”></local:BindableColumnSettings>

    <local:BindableColumnSettings ColumnName=“School” DataContext=“{Binding Path=Data, Source={StaticResource

    proxy}}”

    IsColumnVisible=“{Binding VisibleColB}”></local:BindableColumnSettings>

    </local:FlexGridExtended.BindableSettings>

    I have also attached a sample based on MVVM approach. Please let me know if any other details are needed from my end.
    Regards
    
    [zip filename="CustomColumns-BindingProxy.zip"]https://gccontent.blob.core.windows.net/forum-uploads/file-c90235d7-40db-4e0e-a6eb-2ba8c5b218f9.zip[/zip]
  • Posted 13 January 2022, 8:44 am EST

    Thanks Sonu, this is exactly what I was looking for!

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels