Quantcast
Viewing all articles
Browse latest Browse all 18858

ConvertBack Problem Binding RadioButtons to an Enum

I'm trying to bind radio buttons to an Enum in WPF 4.0.  I don't wish to use the RadioButtons-in-ListBox approach, because, for example, I would like it to work with a nullable Enum with an initial radio button labeled "None" (which isn't one of my Enum constants).

The Convert function is working fine.  I can set the property, and the correct radio button is checked and the others unchecked.

My Enum-to-bool value converter's ConvertBack is initially getting called for each radio button, with one call receiving true and the others false.  The call that receives true is returning the Enum value, and the bound property is properly set and that radio button is checked.  However, for the calls that receive false, I tried returning null and UnsetValue, with the same results, namely, there is a red bounding box around each of my unchecked radio buttons.  As soon as I change the bound Enum, either programmatically or by clicking on an unchecked radio button, the red boxes disappear and everything works great from there, possibly because ConvertBack is never again called with false.

Thank you in advance.


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>