Note that there are some explanatory texts on larger screens.

plurals
  1. POMVVM radiobuttons
    primarykey
    data
    text
    <p>Someone please help. I have an interesting issue. I am trying to implement an MVVM app and I want to bind to radiobuttons in my view. </p> <p>Here's my view:</p> <pre><code>&lt;StackPanel Orientation="Horizontal" Grid.ColumnSpan="2" &gt; &lt;RadioButton GroupName="1" IsChecked="{Binding Path=NoteGeneral, Mode=TwoWay}"&gt;General&lt;/RadioButton&gt; &lt;RadioButton GroupName="1" IsChecked="{Binding Path=NoteContact, Mode=TwoWay}" &gt;Contact&lt;/RadioButton&gt; &lt;RadioButton GroupName="1" IsChecked="{Binding Path=NoteAddress, Mode=TwoWay}" &gt;Address&lt;/RadioButton&gt; &lt;RadioButton GroupName="1" IsChecked="{Binding Path=NotePhone, Mode=TwoWay}" &gt;Phone&lt;/RadioButton&gt; &lt;/StackPanel&gt; </code></pre> <p>Here's my ViewModel:</p> <pre><code> bool _NoteGeneral; public bool NoteGeneral { get { return _NoteGeneral; } set { _NoteGeneral = value; OnPropertyChanged("NoteGeneral"); } } bool _NoteContact; public bool NoteContact { get { return _NoteContact; } set { _NoteContact = value; OnPropertyChanged("NoteContact"); } } bool _NoteAddress; public bool NoteAddress { get { return _NoteAddress; } set { _NoteAddress = value; OnPropertyChanged("NoteAddress"); } } bool _NotePhone; public bool NotePhone { get { return _NotePhone; } set { _NotePhone = value; OnPropertyChanged("NotePhone"); } } </code></pre> <p>The problem is this, when I click the different radiobuttons the property setter only gets called the first time(when i run thru debugging). e.g. When I click NoteGeneral, NoteContact, then NoteGeneral again only the first two clicks update my viewmodel. I think I might have something wrong with my binding, or maybe I'm approaching this the completely wrong way. </p> <p>Can anyone help?</p> <p>How should I implement radiobutton selections in my viewmodel?</p> <h2>.NET 4 and Later</h2> <p>This issue with RadioButton binding was resolved by Microsoft when .NET 4 was released. Binding of RadioButtons now works as you would expect without any of the work-arounds listed below.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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