Binding IsEnabled to IsChecked in WPF

I have a CheckBox and a RadioButton. I need the IsEnabled property to bind to the IsChecked property

<CheckBox x:Name="check_box" Content="CheckBox" IsChecked="True" />

<RadioButton Content="Depending Component" IsChecked="True" Margin="15,3,0,0" IsEnabled="{Binding check_box.IsChecked}" />

      

Is there a way to do this without writing any code?

+3


source to share


1 answer


Yes, you need to use the ElementName binding ( MSDN ):



<CheckBox x:Name="check_box" Content="CheckBox" IsChecked="True" />
<RadioButton IsEnabled="{Binding ElementName=check_box, Path=IsChecked, 
                                 TargetNullValue=false}" .../>

      

+11


source







All Articles