From c77febf4800e626978e7ce8de84cee95a0d38dbb Mon Sep 17 00:00:00 2001 From: brianlagunas_cp Date: Tue, 22 Feb 2011 16:19:24 +0000 Subject: [PATCH] ColorToSolidColorBrushConverter: implemented ConvertBack method. Although not used in the toolkit, a user has requested this functionaltiy and provided a patch. --- .../ColorToSolidColorBrushConverter.cs | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Converters/ColorToSolidColorBrushConverter.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Converters/ColorToSolidColorBrushConverter.cs index 92d7c7ea..6bb19191 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Converters/ColorToSolidColorBrushConverter.cs +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Converters/ColorToSolidColorBrushConverter.cs @@ -8,6 +8,16 @@ namespace Microsoft.Windows.Controls.Core.Converters { #region IValueConverter Members + /// + /// Converts a Color to a SolidColorBrush. + /// + /// The Color produced by the binding source. + /// The type of the binding target property. + /// The converter parameter to use. + /// The culture to use in the converter. + /// + /// A converted SolidColorBrush. If the method returns null, the valid null value is used. + /// public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value != null) @@ -16,9 +26,24 @@ namespace Microsoft.Windows.Controls.Core.Converters return value; } + + /// + /// Converts a SolidColorBrush to a Color. + /// + /// Currently not used in toolkit, but provided for developer use in their own projects + /// The SolidColorBrush that is produced by the binding target. + /// The type to convert to. + /// The converter parameter to use. + /// The culture to use in the converter. + /// + /// A converted value. If the method returns null, the valid null value is used. + /// public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { - throw new NotImplementedException(); + if (value != null) + return ((SolidColorBrush)value).Color; + + return value; } #endregion