1using System.Globalization;
10 private static readonly GridLength zeroLength =
new(0, GridUnitType.Absolute);
13 public object?
Convert(
object? value, Type targetType,
object? parameter, CultureInfo culture)
15 if (value is
string s)
16 return !
string.IsNullOrEmpty(s) ? GridLength.Auto : zeroLength;
17 else if (value is
bool b)
18 return b ? GridLength.Auto : zeroLength;
20 return value is not
null ? GridLength.Auto : zeroLength;
24 public object?
ConvertBack(
object? value, Type targetType,
object? parameter, CultureInfo culture)
26 return value?.ToString() ??
string.Empty;
Automatic length if a property is non-empty.
object ProvideValue(IServiceProvider serviceProvider)
object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)