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..
Hello Adolph,
You may be binding to a property that is not accessible without a TemplateBinding expression. Can you post a sample project or the relevant XAML.Providing a small sample WPF project would ensure I get you back an answer that hits the target the first time.
Thanks!
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
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.