/// <inheritdoc/> public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { if (!ValueConverterHelper.IsValid <string>(value)) { return(DependencyProperty.UnsetValue); } return(ColorConverter.ConvertFromString((string)value)); }
/// <inheritdoc/> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (!ValueConverterHelper.IsValid <string>(value)) { return(DependencyProperty.UnsetValue); } return(new FontFamily((string)value)); }
/// <inheritdoc /> public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { if (!ValueConverterHelper.IsValid <double>(value)) { return(TimeSpan.Zero); } return(TimeSpan.FromMilliseconds((double)value)); }
/// <inheritdoc/> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (!ValueConverterHelper.IsValid <Color>(value)) { return(DependencyProperty.UnsetValue); } return(((Color)value).GetColorName()); }
/// <inheritdoc /> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (!ValueConverterHelper.IsValid <TimeSpan>(value)) { return(0.0); } return(((TimeSpan)value).TotalMilliseconds); }
/// <summary> /// Converts a <see cref="SolidColorBrush"/> to a <see cref="Color"/>. /// </summary> /// <param name="value">The brush.</param> /// <param name="targetType">The type of <see cref="Color"/>.</param> /// <param name="parameter">The converter parameter.</param> /// <param name="culture">The current culture.</param> /// <returns>The color component of a <see cref="SolidColorBrush"/>.</returns> public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { if (!ValueConverterHelper.IsValid <SolidColorBrush>(value)) { return(DependencyProperty.UnsetValue); } return(((SolidColorBrush)value).Color); }
/// <inheritdoc/> public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { if (!ValueConverterHelper.IsValid <FontFamily>(value)) { return(DependencyProperty.UnsetValue); } var fontFamily = (FontFamily)value; return(fontFamily.Source); }
/// <summary> /// Converts a <see cref="Visibility"/> to a <see cref="bool"/> value. /// </summary> /// <param name="value">The <see cref="Visibility"/>.</param> /// <param name="targetType">The type of <see cref="bool"/>.</param> /// <param name="parameter">Parameter is ignored.</param> /// <param name="culture">The current culture.</param> /// <returns>True if <paramref name="value"/> is <see cref="Visibility.Visible"/>. False otherwise.</returns> public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { if (!ValueConverterHelper.IsValid <Visibility>(value)) { return(DependencyProperty.UnsetValue); } var visibility = (Visibility)value; return(visibility == Visibility.Visible); }
/// <summary> /// Converts a <see cref="bool"/> to a <see cref="Visibility"/>. /// </summary> /// <param name="value">The value of the bool to convert.</param> /// <param name="targetType">Type is <see cref="Visibility"/>.</param> /// <param name="parameter">A bool indicating whether the visibility should be collapsed.</param> /// <param name="culture">The culture info.</param> /// <returns><see cref="Visibility.Visible"/> if <paramref name="value"/> is true. /// Otherwise returns <see cref="Visibility.Collapsed"/> except when <paramref name="parameter"/> is false in which case /// <see cref="Visibility.Hidden"/> is returned.</returns> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (!ValueConverterHelper.IsValid <bool>(value)) { return(DependencyProperty.UnsetValue); } var collapse = parameter == null ? true : System.Convert.ToBoolean(parameter); var isVisible = (bool)value; if (isVisible) { return(Visibility.Visible); } else { return(collapse ? Visibility.Collapsed : Visibility.Hidden); } }
/// <inheritdoc /> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (!ValueConverterHelper.IsValid <CustomLabel.TextAlignment>(value)) { return(DependencyProperty.UnsetValue); } switch ((CustomLabel.TextAlignment)value) { case CustomLabel.TextAlignment.Center: return(TextAlignment.Center); case CustomLabel.TextAlignment.Left: return(TextAlignment.Left); case CustomLabel.TextAlignment.Right: return(TextAlignment.Right); default: return(TextAlignment.Center); } }