Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binding IsEnabled to IsChecked in WPF

Tags:

c#

wpf

I've CheckBox and RadioButton. I need bind IsEnabled property to 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 any way to do it without the code writing?

like image 758
MG_REX Avatar asked Nov 04 '14 17:11

MG_REX


1 Answers

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

<CheckBox x:Name="check_box" Content="CheckBox" IsChecked="True" />
<RadioButton IsEnabled="{Binding ElementName=check_box, Path=IsChecked, 
                                 TargetNullValue=false}" .../>
like image 85
BradleyDotNET Avatar answered Nov 13 '22 15:11

BradleyDotNET