In my MainWindow.xaml, I have added my UserControl to the Window. There is also a button that toggles a Boolean value call IsVisible from True/False.
In my MainUserControl.xaml, I have my datagrid(not MS grid) where its tempate points to a Control Template set in the App.xaml. This is where my IsVisible property exists.
In my App.xaml, I have a ControlTemplate which has my datagrid. If I want to bind the Visible property of my Column to the IsVisible property in the MainUserControl class.
I'm having trouble binding the property. I've tried using TemplateBinding, but that can't work since the the TemplatedParent is not the UserControl. I've tried using RelativeSource and setting the Ancestor, but that didn't work either. Does anyone have any advice to help me out?
EDIT: this is the code in my ControlTemplate
<Column FieldName="Column1"
Title="Column1"
Visible="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:UserControl1}, AncestorLevel=2}, Path=IsVisible}" />