-1

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));
  }
}
James Joshua Street
  • 3,259
  • 10
  • 42
  • 80
  • Not implementing `INotifyPropertyChanged` and not RAISING the event are 2 different things. which one are you talking about? – Federico Berasategui Sep 10 '13 at 21:01
  • this may be related, don't know if it applies as you say you actually have the interface in the class: http://stackoverflow.com/questions/7767218/why-does-the-binding-update-without-implementing-inotifypropertychanged – H.B. Sep 10 '13 at 21:02
  • ah i mean not raising the event. doesn't the event have to get raised for the property change to propagate? – James Joshua Street Sep 10 '13 at 21:03

2 Answers2

1

Someone please make it stop working.

Just set the BindingMode to OneTime

H.B.
  • 166,899
  • 29
  • 327
  • 400
0

Since no one had an obvious answer, I knew I had done something wrong elsewhere and what I was posting should work.

Eventually realized it was a bug I had before. Somewhere I had changed the value of the target manually and broke the binding. Need to start checking for code interference with the binding in these situations rather than assuming I am using incorrect syntax for the binding in xaml

James Joshua Street
  • 3,259
  • 10
  • 42
  • 80