I’ve got a question about the binding of checkboxes.
Is it possible to bind a WPF checkbox to a string
with “true” or “false”.
I don’t want to use the boolean variable in binding
<CheckBox x:Name="myCheckBox" IsChecked="{Binding someBooleanVariable}"/>
I want to to do something like
<CheckBox x:Name="myCheckBox" IsChecked="{Binding someStringVariable}"/>
I need that because I want to bind a part of my UI to a Hashmap containing strings. But the UI consists of Textboxes, Checkboxes and Radiobuttons. I want to bind my UI Elements to a function with a parameter for the key of the hashmap. And the function shall return the value of the given key as a string.
You can create and use a custom value converter that converts from string values to booleans. This code looks like it does this (and much more); this gist is much more basic but it’s also a lot less code.