I am trying to bind the visibility property of a DataGridTextColumn in WPF using code. Specifically, I need to bind it to the datacontext of a framework element.
<FrameworkElement x:Name="DataContextControl"/>
In Xaml, I would do :
<DataGridTextColumn Visibility="{Binding DataContext, Source = {x:Reference DataContextControl}}">
I am building the columns dynamically so that's not an option here. How do I do the same binding programmatically since DataGridTextColumn doesn't have a setbinding command?
I have tried using SetValue to no avail.