Is there a way to notify a DependencyObject's bindinigs when the inner DependencyProperties have changed?
For example, I have this class:
public class BackgroundDef : DependencyObject
{
public static readonly DependencyProperty Color1Property =
DependencyProperty.Register("Color1", typeof(Color),
typeof(BackgroundDef), new UIPropertyMetadata(Colors.White));
public static readonly DependencyProperty UseBothColorsProperty =
DependencyProperty.Register("UseBothColors", typeof(bool),
typeof(BackgroundDef), new UIPropertyMetadata(false));
public static readonly DependencyProperty Color2Property =
DependencyProperty.Register("Color2", typeof(Color),
typeof(BackgroundDef), new UIPropertyMetadata(Colors.White));
public Color Color1
{
set { SetValue(Color1Property, value); }
get { return (Color)GetValue(Color1Property); }
}
public bool UseBothColors
{
set { SetValue(UseBothColorsProperty, value); }
get { return (bool)GetValue(UseBothColorsProperty); }
}
public Color Color2
{
set { SetValue(Color2Property, value); }
get { return (Color)GetValue(Color2Property); }
}
}
For which I have 3 separate two-way bindings that set the values for Color1, Color2 and UseBothColors. But I also have a binding for a BackgroundDef instance, which should create a Brush and draw the background of a button (either a single color, or two gradient colors). My problem is that the two-way bindings for the DependencyProperties update the properties, but the binding for the class instance is not called, as apparently the entire object does not change. Any idea how I could call the bindings for the DependencyObject when the DependencyProperties are changed?