Hi, I am using XamDataGrid in my project and grid is showing some fields. 1 field has only two values(say "y" and "N") and based on checkbox value(coming from some other screen via dependency property) we have to show all rows(whether "y" or "N") if unchecked and to show rows only having"N" values if checked.
The dependency property for check box value I am passing in grid but issue is how to alterbatively show or hide XamDataGrid rows based on that dep prop value through data trigger.
Regards
Hitesh
Hello Hitesh,
I have attached a sample project demonstrating the procedures I described in my original response to this forum thread. I hope this helps you.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
Hello Andrew,
Thanks for your response. will try to implement it as per your suggestion thought looking bit complex. is it possible if you can provide any sample, in case feasible for you?
Thank you for your post.
You may have an issue showing and hiding records in the XamDataGrid based on a data trigger. The reason for this is because the XamDataGrid's records are not visual elements, and so they are not able to be directly hidden by usage of a style. You could try to style a DataRecordPresenter element on this matter, but I believe you will likely run into issues with the XamDataGrid's virtualization when you start scrolling if you go this route, as the grid recycles these presenters for performance reasons, and your styling may not hold up.
Instead, I would recommend hooking into a property changed event for this dependency property you are adding to your XamDataGrid. From there, you could programmatically add or remove a filter on the field that is presenting your "Y" or "N" values. Here is a link to an online documentation article that demonstrates how you could programmatically add a filter to the XamDataGrid: http://help.infragistics.com/Help/Doc/WPF/2015.1/CLR4.0/html/xamDataPresenter_Add_Filter_Conditions.html.
If you do wish to try to continue down the styling route, then I would start by writing a style for DataRecordPresenter and defining a MultiDataTrigger in the style's Style.Triggers collection. You will need a MultiDataTrigger because you will need to check both the data item for the record, as well as the dependency property on your XamDataGrid. The data context of a DataRecordPresenter is the DataRecord which it presents. This DataRecord has two properties that may be of use to you: DataPresenter and DataItem. The DataPresenter property will return the XamDataGrid, and so you can use it to bind up to the dependency property on your grid. The DataItem property returns the data item which the DataRecord represents. Through this, you can check the underlying property that shows either "Y" or "N." This can be done through the following sample binding code:
{Binding DataPresenter.MyDependencyPropertyName}{Binding DataItem.MyYorNPropertyName}
By binding a pair of MultiDataTrigger conditions to the above bindings, you can check if both conditions are met and set the MaxHeight of your DataRecordPresenter to 0. I would not recommend setting the Visibility property, as the space for the DataRecord may still remain, and you may end up with a large space between some of your records by going that route.
I hope this helps you. Please let me know if you have any other questions or concerns on this matter.