異なる XAML ファイルの CheckBox に関連する異なるダイアログ (クラス) には、次の 2 つのオプションがあります。
最初のペア:
C#:
public class FirstClass : DependencyObject
{
public static readonly DependencyProperty testProperty =
DependencyProperty.Register("testProperty", typeof(bool),
typeof(FirstClass),
new UIPropertyMetadata(false));
public bool testProperty
{
get { return (bool)this.GetValue(testProperty); }
set { this.SetValue(testProperty, value); }
}
}
XAML:
<CheckBox IsChecked="{Binding Path=testProperty, Mode=TwoWay}">
2 番目のペア:
C#
public class SecondClass : DependencyObject
{
public static readonly DependencyProperty testProperty =
FirstClass.testProperty.AddOwner(typeof(SecondClass));
public bool testProperty
{
get { return (bool)this.GetValue(testProperty); }
set { this.SetValue(testProperty, value); }
}
}
XAML:
<CheckBox IsChecked="{Binding Path=testProperty, Mode=TwoWay}">
最初のダイアログのオプションを 2 番目のダイアログのオプションにバインドしたい (A<=>B)。最初のダイアログの CheckBox がオンになっている場合は、2 番目のダイアログの CheckBox もオンにする必要があります。この目的でApplicationSettingsを使用する必要がありますか?