C# WPF 中的 RadioButton 控件有 IsChecked 属性,可以用来判断是否被选择。

例如,假设你有三个 RadioButton 控件,分别是 radioButton1、radioButton2 和 radioButton3,你可以通过以下代码判断哪个被选中:

if (radioButton1.IsChecked == true)
{
    // radioButton1 被选中
}
else if (radioButton2.IsChecked == true)
{
    // radioButton2 被选中
}
else if (radioButton3.IsChecked == true)
{
    // radioButton3 被选中
}
else
{
    // 没有任何 RadioButton 被选中
}

注意,当没有任何 RadioButton 被选中时,所有 RadioButton 控件的 IsChecked 属性都为 false。

C# WPF RadioButton 选择状态判断 - 代码示例

原文地址: https://www.cveoy.top/t/topic/oUqs 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录