Reputation: 137
I have two checkboxes chkone,chktwo. when i am trying to check the first checkbox(chkone) i am disabling the second checkbox and ischeckd is true, but when i was executed disabling working properly but ischecked in not working?
<CheckBox x:Name="chkone"
Content="QA Review Mandatory" Margin="22,12,289,275"
IsChecked="{Binding Ischkone}"/>
<CheckBox x:Name="chktwo"
Content="Question Mandatory" HorizontalAlignment="Left"
Margin="22,85,0,201" IsChecked="{Binding Ischktwo}">
<CheckBox.Style>
<Style TargetType="CheckBox">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=chkone,Path=IsChecked}" Value="True">
<Setter Property="IsChecked" Value="True"/>
<Setter Property="IsEnabled" Value="False"/>
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=chkone,Path=IsChecked}" Value="False">
<Setter Property="IsChecked" Value="False"/>
<Setter Property="IsEnabled" Value="True"/>
</DataTrigger>
</Style.Triggers>
</Style>
</CheckBox.Style>
</CheckBox>
Upvotes: 1
Views: 15310
Reputation: 413
Try below code and let me know if you are still facing issue,
<CheckBox x:Name="chkone"
Content="QA Review Mandatory" Margin="22,12,289,275"
IsChecked="{Binding Ischkone}"/>
<CheckBox x:Name="chktwo"
Content="Question Mandatory" HorizontalAlignment="Left"
Margin="22,85,0,201" >
<CheckBox.Style>
<Style TargetType="CheckBox">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=chkone,Path=IsChecked}" Value="True">
<Setter Property="IsChecked" Value="True"/>
<Setter Property="IsEnabled" Value="False"/>
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=chkone,Path=IsChecked}" Value="False">
<Setter Property="IsChecked" Value="False"/>
<Setter Property="IsEnabled" Value="True"/>
</DataTrigger>
</Style.Triggers>
</Style>
</CheckBox.Style>
</CheckBox>
Upvotes: 7