3

我遇到了最奇怪的问题,我必须遗漏一些东西。

这是导致错误的我的代码。

if (radLot.Checked == true)
{
    SymbolSpecification = "LotRenderer";
}

if (radWaterMeter.Checked == true)
{
    SymbolSpecification = "WaterMeterRenderer";
}

如您所见,我什至不使用 =+ 或 -=... 我的代码中实际上没有它...任何帮助将不胜感激。

4

3 回答 3

15
于 2012-06-12T20:33:25.070 回答
3

Alternative you can check the CheckState to perform your statement.

 if (radLot.CheckState == CheckState.Checked)
            {

            }

Edit: This will only work when writing a winform application. It will not work with WPF. Use Douglas' answer for WPF.

于 2012-06-12T20:37:28.613 回答
1

This is indeed true - just hit this problem myself converting from Winforms to WPF.

In WPF using:

if (radiobutton1.IsChecked == true)

works

BUT

if (radiobutton1.IsChecked)

Does not.

However in WinForms

if (radiobutton1.Checked)

works but does not in WPF.

于 2015-03-29T20:54:54.277 回答