I have the following object in App.xaml
In a small utility I wrote, I have a list view where the user can hide/show some columns. There is no Visibility property on the columns, so I decided to set the hidden columns width to zero. Not ideal, as the user can still resize them and make them visible again.
Anyway, to do this, I used:
IsThreadIdShown is bound to a check box on the toolbar.
And the multi-value converter is:
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) {
if (values.Length != 2) {
return null;
}
object o0 = values[0];
object o1 = values[1];
if (! (o1 is bool)) {
return o0;
}
bool toBeDisplayed = (bool) o1;
if (! toBeDisplayed) {
return 0.0;
}
if (! (o0 is double)) {
return 0;
}
return (double) o0;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) {
return new object[] { (double)value, Binding.DoNothing };
}