I'm having some trouble with radio button validation in a wpf application, the radiobutton.checked
function it throws an error. the 2 radio buttons are name TSBtn
and DSBtn
. the error that I get when I try and build the application is'
Error 2 The event 'System.Windows.Controls.Primitives.ToggleButton.Checked' can only appear on the left hand side of += or -= 115 23 MainServerWIndow
im not sure why this is happening the code I have Writen is bellow'
private void Bill_Click(object sender, RoutedEventArgs e)
{
if (TSBtn.Checked)
{
StringBuilder itm = new StringBuilder();
foreach (object selectedItem in yourOrder.Items)
{
itm.AppendLine(selectedItem.ToString());
}
MessageBox.Show("The server is " + serversname.SelectedItem + "\n" + "The table number is " + int.Parse(TableNumber.Text) + "\n" + itm);
}
else if (DSBtn.Checked)
{
yourOrder.Items.Add("The driver is " + DriverName.SelectedItem);
yourOrder.Items.Add("Delivery Address " + DeliveryAddress.Text);
}
}
does anyone have any ideas as to why this is happening? thanks.
Checked
is an Event. You should be testing the checked property which is IsChecked
.
So your code should read:
if (TSBtn.IsChecked)
...
and
else if (DSBtn.IsChecked)
...
I've found this question solved at:
if (radLot.IsChecked == true)
{
SymbolSpecification = "LotRenderer";
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.