WPF RadioButton problems and MVVM

As some of you might know, the WPF RadioButton control does not play nice with MVVM.

The scenario that I was facing was as follows:

– I have a ViewModel with PropertyA set to True and PropertyB set to False on init.
– I have a View with two RadioButton controls sharing the same group, and bound to PropertyA and PropertyB on the ViewModel

Since in this case I was using a ViewModel-First approach, when the View is created, the RadioButton OnChecked and OnToggle where setting the True and False values for me behind the scenes.

I finally solved this using the following logic in the property setters:

:) Hope this helps someone.