Hi There,
Been googling this problem for hours, and cannot see where I am going wrong.
I have the following converter which just returns Brushes.Red(have tried Colors.Red) as well but still no luck.
public class ColorConverter : IValueConverter
{
private static ColorConverter instance = new ColorConverter();
public static ColorConverter Instance
{
get
{
return instance;
}
}
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return Brushes.Red;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new Exception("The method or operation is not implemented.");
}
}
Now in my xaml I have the following code:
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Value}" TextAlignment="Center" Foreground="{Binding Path=color, Converter={x:Static local:ColorConverter.Instance}}" Margin="2"/>
</StackPanel>
I have set teh following namespace at the top:
xmlns:local="clr-namespace:Dashboard"
Now I have the following class that is binded to the stack panel:
public class MyClass : INotifyPropertyChanged
{
public String Value;
public Color color;
// Declare the PropertyChanged event
public event PropertyChangedEventHandler PropertyChanged;
public void NotifyPropertyChanged(String info)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}
}
The data binding (Value) works perfectly fine, but the converter does not want to kick in, I tried to set a breakpoint in the Convert method of the covnerter, but that does not get triggered when debugging, it just seems as if my debugger isn't being called.
Can anyone shed some light on this?