I have the following WPF sample program:
Xaml:
Solution proposed by H.B. is really good and has true WPF MVVM spirit. Use it where possible.
In my particular case something went wrong so I came out with different way, as my project is not strict MVVM, so I can use coded solution.
In CustomView.xaml name assigned to column:
...
In CustomView.xaml.cs we have a simple property which directly changes visibility of column:
public Visibility MachinesColumnVisible
{
get { return MachinesColumn.Visibility; }
set
{
if (value == MachinesColumn.Visibility)
return;
MachinesColumn.Visibility = value;
}
}