Forum guidelines
CheckBox Binding
Posted By Toreador on 11 Oct 2008
Hi ,

I have a scenario where my customized checkbox should be able to bind values (IsChecked) anything ex: Y, N or 1, 0 as Booleans. Currently I have implemented the IValueConverter interface and overrided the Convert and ConvertBack method adding my logic to convert the different values into bool appropriately. This works fine. 

But now what I need to do is instead of putting this logic into the class file of customized checkbox, I would like to have all this code in my xaml file itself where I can using Templates configure different values as Booleans. Can you please guide me in achieving the same.

Thanks in Advance.

Re: CheckBox Binding
Posted By Kapil Deo Malhotra on 16 Apr 2009  

You can set checked or unchecked CheckBox in XAML instead doing that in code. I have a property whose value is set either True or False and in XAML i bind the checkbox with that Property

<GridViewColumn Header="Configured Authorization" HeaderContainerStyle="{StaticResource myHeaderStyle}" Width="Auto">
                                <CheckBox IsChecked="{Binding Path=CompAuthConfigValue}"></CheckBox>

Here CompAuthConfigValue is property in the Class which i used. So as the Property changed the CheckBox will be checked or unchecked.

Hope that Helps.

Hope this will help. 
Don't forget to Mark Do you like this Answer

"Don't forget to mark this as Answer"

Kapil Deo Malhotra

C# Corner Annual Conference 2016


Spire.Doc - Free .NET Word API
Use Spire.Doc to create, read, write, print, and convert word documents to OpenXML, RTF, TXT, XPS, EPUB, EMF, HTML, Image and PDF.