Search code examples
c#windows-runtimewindows-store-appsradio-button

Programmatically Checking Radio Button - Windows Store App C#


As the title suggests, I am having some issues when trying to programmatically check a radio button in a Windows 8 Store App. So I realize on a WinForms .NET application I would do something like:

rad.Checked = true;

In WinRT, I am trying this:

control.RadYes.IsChecked = true;

This is what I would assume would cause the Radio Button to be pressed; however, in the UI, it still shows nothing is checked. If I place a breakpoint, I can hover over RadYes, and it shows the property = true. Is this not the correct way to do this?

The idea, is I am allowing a user to pick back up where they left on when filling out a form. So it retrieves the values from the database and correctly getting into my switch/case to set the value--but the UI doesn't change.

Another thing I noticed that I am also about to try--is that I didn't assign a Group to my 3 Radio Buttons. Can someone clue me in as to what I might be doing wrong? Thanks!


Solution

  • OK, so my solution was to add GroupName="YesNoNA" in the XAML controls. I didn't change anything else, and now it works. I searched for an hour trying to find information about this, so hopefully this will help someone else out.