Enable/disable textbox based on checkbox selection in WPF using MVVM

Just bind the IsEnabled property of the TextBox to the IsChecked property of the CheckBox:

<CheckBox Name="checkBox1" />
<TextBox IsEnabled="{Binding ElementName=checkBox1, Path=IsChecked}" />

if you have 40 controls like this, I would create a new control containing the checkbox and the textbox. The you can use that new control without the need to implement 40 commands, instead your new control has a single command implementation. and this is also less code to maintain as additional benefit

Tags:

Wpf

Mvvm