Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3971
  • Last Modified:

WPF - Uncheck a checked Radio Button

Hi Experts,

How do I uncheck a radiobutton that is checked and make it so all the other radiobuttons in the group are unchecked as well.

Thanks.
0
OFGemini
Asked:
OFGemini
  • 5
  • 3
  • 2
  • +1
1 Solution
 
BardobraveCommented:
I supose that you must set it's value to 0?
0
 
Bob LearnedCommented:
Set the IsChecked property = true or false:

ToggleButton.IsChecked Property
http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.togglebutton.ischecked.aspx
0
 
Roopesh ReddyIT AnalystCommented:
Hi,

Check the below article - http://blog.bradcunningham.net/2009/09/grouping-and-checkboxes-in-wpf.html

Hope it helps u...
0
Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

 
OFGeminiAuthor Commented:
Sorry let me put more detail here.

How do you uncheck a Checked checkbox from the UI? I want to be able about to click the radiobutton again to uncheck it.
0
 
Roopesh ReddyIT AnalystCommented:
Hi,

You may have to write a custom logic for that!

May be you have handle the onclick event of the RadioButton and make is selected or not based on your requirement!

Best suited control for your scenario is CheckBox!

Hope it helps u...
0
 
OFGeminiAuthor Commented:
Hello, I extended a Radio button and added this and it seems to work for me.

        private void RadioButtonExtended_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {


            if (IsChecked.HasValue && IsChecked.Value)
                IsChecked = false;
            e.Handled = true;
        }
0
 
Bob LearnedCommented:
That is contrary to the way that radio buttons work, and users are usually not very happy with that kind of decision.  What it sounds like, is that you need CheckBox controls, instead of a RadioButton.
0
 
Roopesh ReddyIT AnalystCommented:
Hi,

Yeah! Good that it's working for you!
0
 
OFGeminiAuthor Commented:
Hi learned one,

Yes, it does seem like the checkbox is what I need, but with checkboxes none or all the checkboxes on a form can be checked.  In my scenario, I need none or only one to be checked.  I can see how I'm not using the radio button correctly.  I could have created logic to uncheck all other checkboxes when one is checked, but I think the radio button suits my scenario a little better.
0
 
OFGeminiAuthor Commented:
Hi learnedone,

I could have put an extra radio button that is the 'none selected' option as well.
0
 
OFGeminiAuthor Commented:
I found a solution on my own
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 5
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now