我遇到了最奇怪的问题,我必须遗漏一些东西。
这是导致错误的我的代码。
if (radLot.Checked == true)
{
SymbolSpecification = "LotRenderer";
}
if (radWaterMeter.Checked == true)
{
SymbolSpecification = "WaterMeterRenderer";
}
如您所见,我什至不使用 =+ 或 -=... 我的代码中实际上没有它...任何帮助将不胜感激。
我遇到了最奇怪的问题,我必须遗漏一些东西。
这是导致错误的我的代码。
if (radLot.Checked == true)
{
SymbolSpecification = "LotRenderer";
}
if (radWaterMeter.Checked == true)
{
SymbolSpecification = "WaterMeterRenderer";
}
如您所见,我什至不使用 =+ 或 -=... 我的代码中实际上没有它...任何帮助将不胜感激。
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.
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
.