I have a DataGrid bound to a ViewModel's property of type ObservableCollection. Inside DataGrid I have several DataGridTextColumns bound to item of the ObservableCollection. I need to access parent DataContext (ViewModel) to set Visibility property of one of the DataGridTextColumns. There is a solution suggested over the internet:
{Binding DataContext.IsColumnVisible, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type MyControl}}}
IsColumnVisible property is of type System.Windows.Visibility. Such solution works for other properties like DataGridTextColumn.Binding, but doesn't for DataGridTextColumn.Visibility! Is there solution for Visibility?
EDIT: I finally adopted the following solution: Bind datagrid column visibility MVVM