VividDreaming
VividDreaming

Reputation: 15

Radiobutton "Checked" method doesn't work

I have an unknown problem with building my first UWP App.

On button onclick method I want to check if one of checkboxes is checked and if yes I want to open a new frame:

namespace IDG
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
        }

        private void bt_start_Click(object sender, RoutedEventArgs e)
        {
            if (rb_quiz.Checked)
            {
                this.Frame.Navigate(typeof(Page2));
            }
        }
    }
}

Visual Studio marks error on that line: if (rb_quiz.Checked)

The popup says:

The Event 'ToggleButton.Checked' can only appear on the left hand side of += or -"

I have checked "==Checked" or "isChecked". But nothing works. My radiobutton is called rb_quiz.

Upvotes: 1

Views: 1699

Answers (2)

Owen Pauling
Owen Pauling

Reputation: 11841

According to the documentation, Checked is an event that "Fires when a ToggleButton is checked". You instead want to use the property IsChecked

Upvotes: 0

Manfred Radlwimmer
Manfred Radlwimmer

Reputation: 13394

Checked is an Event, you are looking for IsChecked which is a Nullable<Boolean>.

Try this:

if (rb_quiz.IsChecked == true)

Upvotes: 1

Related Questions