【问题标题】:Radiobutton "Checked" method doesn't work单选按钮“已检查”方法不起作用
【发布时间】:2016-09-12 04:25:41
【问题描述】:

我在构建我的第一个 UWP 应用时遇到未知问题。

按钮 onclick 方法我想检查是否选中了一个复选框,如果是,我想打开一个新框架:

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 在该行标记错误: if (rb_quiz.Checked)

弹出窗口说:

事件 'ToggleButton.Checked' 只能出现在 += 或 - 的左侧

我已检查“==Checked”或“isChecked”。但没有任何效果。我的radiobutton 被称为rb_quiz

【问题讨论】:

    标签: c# radio-button win-universal-app checked


    【解决方案1】:

    Checked 是一个事件,您正在寻找IsChecked 这是一个Nullable&lt;Boolean&gt;

    试试这个:

    if (rb_quiz.IsChecked == true)
    

    【讨论】:

      【解决方案2】:

      根据the documentationChecked 是一个“在选中 ToggleButton 时触发”的事件。相反,您想使用属性IsChecked

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-01-11
        • 1970-01-01
        • 2012-06-04
        • 2018-01-17
        • 2014-08-05
        相关资源
        最近更新 更多