Tuesday, May 21, 2013

Checkbox WPF – Making checkbox readonly in WPF


As the title suggests, following is the way by which you can make a checkbox readonly in WPF.
Let’s have a look at typical checkbox XAML –
<CheckBox Content="CheckBox" Name="checkBox1" />
Now to make this checkbox read only – we need to add two following properties to XAML statement above.

Those two Properties are – IsHitTestVisible and Focusable
Make thse two properties to False. This makes the readonly checkbox in WPF.
So final XAML statement will be as follows for readonly checkbox in WPF –  

<CheckBox Content="CheckBox" Name="checkBox1" IsHitTestVisible="False" Focusable="False"/> 

Hope this helps.

Cheers…

Happy Coding!!

2 comments: