I have a XamDataGrid and I'd like to make one of the fields visible on a per-row basis. Meaning, I have a boolean field (let's call it HavingABlast) and it's represented by a checkbox. This is a field on a grid, let's say it's a grid of today's activities. For some of those activities, I want to be able to check the HavingABlast checkbox. For other activities (say, "begging for help on the forums") HavingABlast does not apply, and I don't want to even display it.
With WPF and standard DataBinding, I create a second field on my ViewModel called "HavingABlastSectionVisibility" and set it in my ViewModel appropriately. Then, armed with this knowledge on a row-by-row basis, I do:
<CheckBox IsChecked="{Binding HavingABlast}" Visibility="{Binding HavingABlastSectionVisibility}" />
IsChecked="{Binding HavingABlast}"
Visibility="{Binding HavingABlastSectionVisibility}" />
Unfortunately I'm new to XamDataGrids and I'm not sure how to create this effect. So...any tips? How do I hide a field on a row-by-row basis in a XamDataGrid?
Here's my (broken) XAML:
<!-- broken --> <igDP:Field Name="HavingABlast" Label="Having a blast?" Visibility="{Binding Path=DataItem.HavingABlastSectionVisibility}"/>
<igDP:Field
Name="HavingABlast"
Label="Having a blast?"
Visibility="{Binding Path=DataItem.HavingABlastSectionVisibility}"/>
Thanks for the answer. I had seen that post but it applies to the whole data set, not an individual row/record. Either way, I'll have to figure something different out. Maybe do some craziness on the ViewModel to pass in a complex object with a Visibility property that I can reference in a CustomCellPresenter. I didn't want to have to resort to that, but it will be okay. -Peter
Hello,
The Fields are not in the visual tree of the application, so you cannot use such binding to bind to their properties. However, you can try this trick here to go around this.