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.


anything to say?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s