内部の DependencyProperties が変更されたときに DependencyObject のバインディングを通知する方法はありますか?
たとえば、次のクラスがあります。
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); }
}
}
Color1、Color2、および UseBothColors の値を設定する 3 つの個別の双方向バインディングがあります。しかし、BackgroundDef インスタンスのバインドもあり、Brush を作成してボタンの背景 (単一色または 2 つのグラデーション色) を描画する必要があります。私の問題は、DependencyProperties の双方向バインディングがプロパティを更新することですが、明らかにオブジェクト全体が変更されないため、クラス インスタンスのバインディングは呼び出されません。DependencyProperties が変更されたときに DependencyObject のバインディングを呼び出す方法はありますか?