//================USE Following in Resources====================
//=========Use following converter class in codebehind================
[ValueConversion(typeof(bool), typeof(Color))]
public class StringToColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value)
return Color.FromRgb(255,0,0);//red
else
return false;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException("ConverBack should never be called");
}
}
|