Reputation: 4240
I have a set of radio buttons. In some cases I want the user to be able to select more than one of these radio buttons.
I use the logic that if I want the user to only select on of the radio buttons I add them to the same radiobuttongroup. If I want the user to be able to select mutltiple I add each one to thier own radiobuttongroup.
The issue I have is that when I select a radio button in a group by itself I can then not deselect it.
Could someone please advise why this is happening and suggest a different way of doing this?
Upvotes: 1
Views: 3805
Reputation: 1050
I remember I was able to do it on an old XAML/WPF project. Today I was looking for it implementing this on XAML/Windows Phone 8, and it seems that is kind of difficult to do.
Luckily I found this article: http://social.msdn.microsoft.com/Forums/vstudio/en-US/f0f6587b-8a08-4c6c-b071-802d104a35da/how-to-uncheck-all-radiobuttons-in-a-group?forum=wpf
Basically, you have to set IsChecked in False for all the buttons that are into the same Group. (BTW I have set IsThreeState in default value).
I hope this helps.
Cheers, Herber
Upvotes: 0
Reputation: 21
RadioButton in WFP has a boolean property IsChecked
, which can be set to false
. To reset radio buttons in a group you should set IsChecked
to false for all (or just for a radio button which IsChecked
is true).
Upvotes: 2
Reputation: 45106
If you select the checked radio button the binding sets a value of true. If the current value and proposed value are true then set it to false. Hey it works for me.
public bool chcked
{
get { return c; }
set
{
if (c && value)
{
c = false;
return;
}
c = value;
}
}
Upvotes: 0
Reputation: 263
Radiobuttons cant be unchecked. You have to use normal checkboxes in this context. In the Checked Event of the checkbox, you can for example uncheck another checkboxes. Its not a nice way, but it works.
Upvotes: 3