locked
checking checkbox from button event handler

    Question

  • First of all, I apologize for the newbie question.  Please don't kill me.

    How do I check to see a checkbox is checked from within button event handler? 

    void FEPrepPart1::test::answer(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
    {
    
    
    }

     We'll just call the checkbox checkbox.  I've tried every if statement I could think of.  Can't get it to work.

    Tuesday, June 18, 2013 12:25 AM

All replies

  • Assuming your event handler isn't for the Checkbox::Checked or Unchecked events (in which case you can tell based on the event), you can look at the Checkbox's IsChecked property.

    Another way would be to bind the Checkbox's IsChecked property to a value in your code and then look at the bound property.

    --Rob

    Tuesday, June 18, 2013 12:39 AM
    Owner
  • Assuming your event handler isn't for the Checkbox::Checked or Unchecked events (in which case you can tell based on the event), you can look at the Checkbox's IsChecked property.

    Another way would be to bind the Checkbox's IsChecked property to a value in your code and then look at the bound property.

    --Rob

    I've already looked at that page before.  I've no idea how to use that info.

    Added by edit.

    I'm thinking it should be something like

    if(checkbox.IsChecked==true) {

    .....

    }

    Am I right?

    Added by edit again.

    I'm sorry if I wasn't clear before.

    I've got a checkbox.  I've got a button.  The event handler is for the button.  What is the if statement that allows me to check if the checkbox is checked or not?

    • Edited by RandyPete Tuesday, June 18, 2013 1:09 AM
    Tuesday, June 18, 2013 1:05 AM
  • The syntax you have there would work for C#. For C++ you need:

    if (checkbox->IsChecked)
    {
       // ....
    }
    --Rob
    Tuesday, June 18, 2013 1:17 AM
    Owner
  • The syntax you have there would work for C#. For C++ you need:

    if (checkbox->IsChecked)
    {
       // ....
    }
    --Rob

    I responded too soon before.  I'm seeing that it doesn't check if it's checked or unchecked.  What should I put to make it check where the checkbox is checked or unchecked?

    Edited.

    Figured it out. 

    if(checkbox->IsChecked->Value) {

    ...

    }

    It means IsChecked==true.

    • Edited by RandyPete Tuesday, June 18, 2013 2:18 AM
    Tuesday, June 18, 2013 1:49 AM