<sfButtons:SfCheckBox x:Name="CheckBox1" Text="Combo 1" IsChecked="{Binding IsCheckBox1Checked}" Grid.Row="1" Grid.Column="0" Margin="10,0,20,0"/>
<sfButtons:SfCheckBox x:Name="CheckBox2" Text="Combo 2" IsChecked="{Binding IsCheckBox2Checked}" Grid.Row="1" Grid.Column="1" Margin="20,0,10,0"/> |
private bool chk_CheckBox1;
private bool chk_CheckBox2;
public bool IsCheckBox1Checked
{
get { return chk_CheckBox1; }
set
{
chk_CheckBox1 = value;
if (chk_CheckBox1)
IsCheckBox2Checked = false;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsCheckBox1Checked"));
}
}
public bool IsCheckBox2Checked
{
get { return chk_CheckBox2; }
set
{
chk_CheckBox2 = value;
if (chk_CheckBox2)
IsCheckBox1Checked = false;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsCheckBox2Checked"));
}
} |
<sfButtons:SfCheckBox x:Name="CheckBox3" Text="Combo 3" Grid.Row="3" Grid.Column="0" Margin="10,0,20,0">
<sfButtons:SfCheckBox.Triggers>
<EventTrigger Event="StateChanged">
<local:CheckStateValidationTriggerAction OpponentCheckBox="{x:Reference CheckBox4}"/>
</EventTrigger>
</sfButtons:SfCheckBox.Triggers>
</sfButtons:SfCheckBox>
<sfButtons:SfCheckBox x:Name="CheckBox4" Text="Combo 4" Grid.Row="3" Grid.Column="1" Margin="20,0,10,0">
<sfButtons:SfCheckBox.Triggers>
<EventTrigger Event="StateChanged">
<local:CheckStateValidationTriggerAction OpponentCheckBox="{x:Reference CheckBox3}"/>
</EventTrigger>
</sfButtons:SfCheckBox.Triggers>
</sfButtons:SfCheckBox> |
public class CheckStateValidationTriggerAction : TriggerAction<SfCheckBox>
{
public SfCheckBox OpponentCheckBox { get; set; }
protected override void Invoke(SfCheckBox checkbox)
{
if(OpponentCheckBox != null)
{
OpponentCheckBox.IsChecked = !checkbox.IsChecked;
}
}
} |