By default, WPF ToggleButton or CheckBox (which inherits ToggleButton) doesn't have some kind of ReadOnly property to prevent user from changing the value.
One technic consists in setting IsHitTestVisible="False" and Focusable="False".
I thought that I could also achieve this binding the IsChecked property to a get only accessor.
Bound model
class SomeViewModel
{
public bool Checked => true;
}
View
<CheckBox IsChecked="{Binding Checked, Mode=OneWay}">
But unfortunately, this is not working, the user can still change the CheckBox value...
In this case unfortunately, the binding is getting out of synchronization when user changes the value.
Below a solution which consists in always refreshing the binding when the user changes the value.
ToggleButtonEx class
Usage