Nach dem Ändern von CheckBox.IsChecked von DataTrigger Quellwert, an den CheckBox.IsChecked gebunden hat, ändert sich nicht.CheckBox-Bindung aktualisiert die Quelle nicht
Ich habe einfach Ansichtsmodell
public class ViewModel : INotifyPropertyChanged
{
private bool check1;
public bool Check1
{
get { return check1; }
set { check1 = value; NotifyPropertyChanged(); }
}
private bool check2;
public bool Check2
{
get { return check2; }
set { check2 = value; NotifyPropertyChanged(); }
}
#region Notify
...
#endregion
}
und einfache XAML
<StackPanel Grid.Row="1">
<CheckBox Content="Check1">
<CheckBox.Style >
<Style TargetType="{x:Type CheckBox}">
<Setter Property="IsChecked" Value="{Binding Check1, Mode=TwoWay}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Check2}" Value="True">
<Setter Property="IsChecked" Value="True"/>
</DataTrigger>
</Style.Triggers>
</Style>
</CheckBox.Style>
</CheckBox>
<CheckBox Content="Check2" IsChecked="{Binding Check2}"/>
<TextBlock Text="{Binding Check1}" Name="uiCheckValue1"/>
<TextBlock Text="{Binding Check2}" Name="uiCheckValue2"/>
</StackPanel>
Wenn ich checkbox2 überprüfen die CheckBox1 geprüft wird aber Quelle nicht aktualisiert. Wie kann ich die Quelle aktualisieren?
Try "{Binding Check1, Mode = TwoWay]" –