public Convert ( object value, |
||
value | object | The value produced by the binding source. |
targetType | The type of the binding target property. | |
parameter | object | The converter parameter to use. |
culture | System | The culture to use in the converter. |
return | object |
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var visible = value != null && !string.IsNullOrEmpty(value.ToString());
if (parameter != null && string.Equals("not", parameter.ToString(), StringComparison.OrdinalIgnoreCase))
{
visible = !visible;
}
return visible ? Visibility.Visible : Visibility.Collapsed;
}
public void Null_With_Not_Param_Converts_To_Visible() { var conv = new NullEmptyCollapsedConverter(); var result = conv.Convert(null, typeof(Visibility), "not", CultureInfo.CurrentCulture); Assert.AreEqual(Visibility.Visible, result); }