I have a class that implements Inotifypropertychanged. I also have this property that I commented out the notification on.
private Color _CoolColor =Colors.Purple;
public Color CoolColor
{
get
{
return _CoolColor;
}
set
{
if (value != _CoolColor)
{
_CoolColor = (Color)value;
//OnPropertyChanged("CoolColor");
}
}
}
a binding in my xaml attaches to this property:
BusTextColor="{Binding Path=CoolColor}"
/// <summary>
/// Color used for the text containing the hex value of the bus
/// </summary>
public Color BusTextColor
{
get
{
return (Color)GetValue(BusTextColorProperty);
}
set
{
SetValue(BusTextColorProperty, value);
}
}
public static readonly DependencyProperty BusTextColorProperty =
DependencyProperty.Register("BusTextColor",
typeof(Color), typeof(SignalGraph),
new FrameworkPropertyMetadata(new Color(), new PropertyChangedCallback(CreateBrushesAndReDraw)));
I only bound this cause I wanted to make sure that I wasn't crazy, but I must be crazy because my BusTextColor is updating when CoolColor changes. Someone please make it stop working.
I was only doing this because another dependency property I have is not binding to my viewmodel properly. I know there is probably some obvious reason for this, but I'm definitely missing it.
edit: that article was interesting. but in my case I have the Inotifypropertychanged interface implemented, I just don't raise the event OnPropertyChanged. I realized I should have posted that as well.
protected void OnPropertyChanged(string name)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(name));
}
}