/// <summary> /// Convert Visibility back to bool. /// </summary> /// <param name="value">A value. Only value of type <see cref="T:System.Windows.Visibility" /> is supported,</param> /// <param name="targetType">A targettype, currently not used.</param> /// <param name="parameter">A parameter value, currently not used.</param> /// <returns> /// When value is Visibility.Visible then true else false. /// </returns> protected override object ConvertBack(object value, Type targetType, object parameter) { if (value is Visibility) { var isVisible = (Visibility)value == Visibility.Visible; // Note: base class will doesn't implement ConvertBack so we need to invert ourselves if (SupportInversionUsingCommandParameter && ConverterHelper.ShouldInvert(parameter)) { isVisible = !isVisible; } return(isVisible); } return(false); }
/// <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)); }