I'm trying to bind the Visibility of a Field to a property on the User Control in th XamDataGrid. I am aware that you cannot use standard WPF binding because it is not part of the element/visual tree of the application. I tried to use Josh Smith's article to solve this problem but I am unable to apply this solution using a User Control. The example uses a Window. Can someone help me out?
Thanks in advance..
Hi there,
Look in the WPF NetAdvantage Feature Browser sample at the XamDataGrid, Control Composition, Adorning Editors example. This shows how to use a DataTrigger binding within a CellValuePresenter. You could use this example to bind a data property to the Visibility of the cell (field). You may need to create a property in your data (a view model property for example) that is bound to both the UserControl property and to the cell property - this depends on where the UserControl lives.
If this suggestion does not simplify what you need to do, refactor your issue into a small sample project with a similar UserControl and the grid code and the area you want to modify visibility. Post the project in a zip archive and I will update it to make it work and re-post it here.
Hi Curtis,
Thanks for the reply. I looked at the example you referenced in the previous email. If I try to bind
any property to the Visibility of the cell I get the following message:
Cannot find governing FrameworkElement or FrameworkContentElement for target element.
Regards,
Adolph