Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><a href="http://blogs.msdn.com/jaimer/default.aspx" rel="noreferrer">Jaime Rodriguez</a>, who works at Microsoft on WPF, publishes an unabridged Q&amp;A on WPF, and the latest issue has a post on RadioButtons and MVVM !</p> <p>The post is at <a href="http://blogs.msdn.com/jaimer/archive/2009/09/22/wpf-discussion-090922.aspx" rel="noreferrer">http://blogs.msdn.com/jaimer/archive/2009/09/22/wpf-discussion-090922.aspx</a>, and you want to look at the last item in that post. I tested the solution and it works to my satisfaction.</p> <p>Quoted for convenience:</p> <blockquote> <p>I've worked around this issue in .NET 3.5 SP1. Here's how I data bind a group of radio buttons to an enum-valued property:</p> </blockquote> <pre><code>&lt;StackPanel&gt; &lt;RadioButton Content="New folder" IsChecked="{Binding Path=PublishTarget, Converter={StaticResource equalityConverter}, ConverterParameter={x:Static local:PublishTarget.NewServerFolder}, Mode=TwoWay}" GroupName="1" /&gt; &lt;RadioButton Content="Existing folder" IsChecked="{Binding Path=PublishTarget, Converter={StaticResource equalityConverter}, ConverterParameter={x:Static local:PublishTarget.ExistingServerFolder}, Mode=TwoWay}" GroupName="2" /&gt; &lt;RadioButton Content="Local folder" IsChecked="{Binding Path=PublishTarget, Converter={StaticResource equalityConverter}, ConverterParameter={x:Static local:PublishTarget.LocalFolder}, Mode=TwoWay}" GroupName="3" /&gt; &lt;/StackPanel&gt; </code></pre> <blockquote> <p>Setting each radio button's GroupName to a unique value prevents the bindings from getting clobbered when the user clicks on a radio button. Here I'm relying on the data source to implement INotifyPropertyChanged, which will tell the other radio buttons to update. A similar approach should work for radio buttons in an ItemsControl.</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload