What do I have to change to the following code so that the background is red, neither of the 2 ways I tried worked:
(source: deviantsart.com)
I figured this out, it was just a naming conflict issue: if you use TheBackground instead of Background it works as posted in the first example. The property Background was interfering with the Window property background.
Here you've got a copy-paste code:
class NameToBackgroundConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if(value.ToString() == "System")
{
return new SolidColorBrush(System.Windows.Media.Colors.Aqua);
}else
{
return new SolidColorBrush(System.Windows.Media.Colors.Blue);
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}