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
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.
Stefan,
Thanks, but in my case I can't add my view model to view's local resources because view model constructor has an argument. I set DataContext for the view in view's constructor.
I have been modified the sample I sent you before, so now there is no parameterless constructor as StaticResource. I added the Window’s DataContext object as Resource an used it. Please let me know if this helps you or you need further assistance on this matter.
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.
It works, than you very much!