/// <summary> /// Modifies the source data before passing it to the target for display in the UI. /// </summary> /// <param name="value">The source data being passed to the target.</param> /// <param name="targetType">The <see cref="T:System.Type" /> of data expected by the target dependency property.</param> /// <param name="parameter">An optional parameter to be used in the converter logic.</param> /// <returns>The value to be passed to the target dependency property.</returns> protected override object Convert(object value, Type targetType, object parameter) { bool isNull = value == null; bool invert = ConverterHelper.ShouldInvert(parameter); return(invert ? isNull : !isNull); }
/// <summary> /// Determines what value this converter should return. /// </summary> /// <param name="value">The value produced by the binding source.</param> /// <param name="targetType">The type of the binding target property.</param> /// <param name="parameter">The converter parameter to use.</param> /// <returns> /// <c>true</c> if the specified value is visible; otherwise, <c>false</c>. /// </returns> protected override bool IsVisible(object value, Type targetType, object parameter) { bool invert = ConverterHelper.ShouldInvert(parameter); string stringValue = value as string; if (invert) { return(string.IsNullOrEmpty(stringValue)); } return(!string.IsNullOrEmpty(stringValue)); }
/// <summary> /// Determines what value this converter should return. /// </summary> /// <param name="value">The value produced by the binding source.</param> /// <param name="targetType">The type of the binding target property.</param> /// <param name="parameter">The converter parameter to use.</param> /// <returns> /// <c>true</c> if the specified value is visible; otherwise, <c>false</c>. /// </returns> protected override bool IsVisible(object value, Type targetType, object parameter) { bool invert = ConverterHelper.ShouldInvert(parameter); return(invert ? (value == null) : (value != null)); }