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
1690
Hide columns for xamGrid (MVVM)
posted

Hi,

I use xamGrid (not xamDataGrid) and I would like to hide/display some columns depending on checkbox selection. I tried to set Visibility property for column:

<ig:XamGrid ItemsSource="{Binding CountyData}" AutoGenerateColumns="False">

...

<ig:TextColumn Key="Total" Width="70" IsHideable="true"
     Visibility="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:CountyInputViewModel}},

     Path=IncludeCount, Converter={StaticResource boolToVisibilityConverter}}">

     <ig:TextColumn.HeaderTemplate>
          <DataTemplate>
              <TextBlock Text="Total" TextWrapping="Wrap" />
          </DataTemplate>
     </ig:TextColumn.HeaderTemplate

</ig:TextColumn>

where in my view model I declare public bool IncludeCount binded to checkbox and public ObservableCollection<CountyInputData> CountyData

However it does not work, columns are static. What can be wrong ?

Thanks,

Ed

Parents
No Data
Reply
  • 138253
    Offline posted

    Hello Ed,

     

    Thank you for your post. I have been looking into it and I created a sample project for you with the functionality you want. Basically I implemented InotifyPropertyChanged interface in my ViewModel and set TwoWay Binding in the CheckBox. Please let me know if this helps you or you need further assistance on this matter.

     

    Looking forward for your reply.

    XamGridColumnsVisibility.zip
Children