There is a checkbox and combobox. ComboBox should be inactive if there is a daw in CheckBox and active if it is not. I know how to do Binding in the standard case, when everything is the opposite - if IsChecked = true => then IsEnabled = true.

<CheckBox Name="CheckBox_Autoselect" IsChecked="True" /> <ComboBox IsEnabled="{Binding ElementName=CheckBox_Autoselect, Path=IsChecked}"> <ComboBoxItem Content="Type 1"/> <ComboBoxItem Content="Type 2"/> </ComboBox> 

And if you need to do this: IsChecked = true => IsEnabled = false, is it possible to implement this in a similar way - only Binding, without C # code?

  • This is done using a converter. - ixSci
  • @ixSci, I saw a method with a converter, IsEnabled = "{Binding Path = IsReadOnly, Converter = {StaticResource InverseBooleanConverter}}" and C # code. If the question was only how to do it, I would not ask. - Max
  • one
    There is no other way. You can even write your Binding, but it is a bit more complicated :) - ixSci
  • @ixSci, ok, thanks. - Max

2 answers 2

Look at this link https://social.msdn.microsoft.com/Forums/vstudio/en-US/98c224af-cac0-4108-88bb-1e97d701e3a8/checkbox-trigger-enabledisable-textbox?forum=wpf or an adapted version for you

 <ComboBox Grid.Row="2"> <ComboBox.Style> <Style> <Setter Property="ComboBox.IsEnabled" Value="True"/> <Style.Triggers> <DataTrigger Binding="{Binding ElementName=checkBox, Path=IsChecked}" Value="True"> <Setter Property="ComboBox.IsEnabled" Value="False" /> </DataTrigger> </Style.Triggers> </Style> </ComboBox.Style> </ComboBox> <CheckBox Name="checkBox" Grid.Row="3"/> 
  • In the version of the link because there is no inversion. It is a pity that there is no built-in short version in one line. Thanks for the solution. - Max

Try this option: https://www.nuget.org/packages/CalcBinding/

Syntax:

 <CheckBox Content="!IsChecked" IsChecked="{c:Binding !IsChecked}"/> 

Examples can be found here.