Keep getting this error: The event 'System.Windows.Controls.Primitives.ToggleButton.Checked' can only appear on the left hand side of += or -=

后端 未结 1 1508
一个人的身影
一个人的身影 2021-01-22 21:23

I keep getting this error when making the program as given below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sys         


        
1条回答
  •  囚心锁ツ
    2021-01-22 22:12

    Checked here is an event, not a bool, that happens when it is checked. You need a different property - presumably IsChecked.

    Minor note, but stylistically, it is usually preferable not to compare booleans to true/false, but rather:

            if (rbadd.IsChecked)
                c = a + b;
            else if (rbsubtract.IsChecked)
                c = a - b;
            else if (rbdivide.IsChecked)
                c = a / b;
    

    etc; or if you wanted to test for false: if(!rbadd.IsChecked).

    0 讨论(0)
提交回复
热议问题