问题描述
MainWindos.xaml文件代码:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Windows;usingSystem.Windows.Controls;usingSystem.Windows.Data;usingSystem.Windows.Documents;usingSystem.Windows.Input;usingSystem.Windows.Media;usingSystem.Windows.Media.Imaging;usingSystem.Windows.Navigation;usingSystem.Windows.Shapes;namespaceMathsOperators{///<summary>///InteractionlogicforMainWindow.xaml///</summary>publicpartialclassMainWindow:Window{publicMainWindow(){InitializeComponent();}privatevoidcalculateClick(objectsender,RoutedEventArgse){try{if((bool)addition.IsChecked)addValues();elseif((bool)subtraction.IsChecked)subtractValues();elseif((bool)multiplication.IsChecked)multiplyValues();elseif((bool)division.IsChecked)divideValues();elseif((bool)remainder.IsChecked)remainderValues();}catch(Exceptioncaught){expression.Text="";result.Text=caught.Message;}}privatevoidaddValues(){intlhs=int.Parse(lhsOperand.Text);intrhs=int.Parse(rhsOperand.Text);intoutcome;outcome=lhs+rhs;expression.Text=lhsOperand.Text+"+"+rhsOperand.Text;result.Text=outcome.ToString();}privatevoidsubtractValues(){intlhs=int.Parse(lhsOperand.Text);intrhs=int.Parse(rhsOperand.Text);intoutcome;outcome=lhs-rhs;expression.Text=lhsOperand.Text+"-"+rhsOperand.Text;result.Text=outcome.ToString();}privatevoidmultiplyValues(){intlhs=int.Parse(lhsOperand.Text);intrhs=int.Parse(rhsOperand.Text);intoutcome;outcome=lhs*rhs;expression.Text=lhsOperand.Text+"*"+rhsOperand.Text;result.Text=outcome.ToString();}privatevoiddivideValues(){intlhs=int.Parse(lhsOperand.Text);intrhs=int.Parse(rhsOperand.Text);intoutcome;outcome=lhs/rhs;expression.Text=lhsOperand.Text+"/"+rhsOperand.Text;result.Text=outcome.ToString();}privatevoidremainderValues(){intlhs=int.Parse(lhsOperand.Text);intrhs=int.Parse(rhsOperand.Text);intoutcome;outcome=lhs%rhs;expression.Text=lhsOperand.Text+"%"+rhsOperand.Text;result.Text=outcome.ToString();}privatevoidquitClick(objectsender,RoutedEventArgse){this.Close();}privatevoidlhsOperand_TextChanged(objectsender,TextChangedEventArgse){}privatevoidrhsOperand_TextChanged(objectsender,TextChangedEventArgse){}}}MainWindow.xaml.cs代码:Title="MathsOperators"Height="382"Width="367"><Grid><LabelHeight="31.2766666666667"HorizontalAlignment="Left"Margin="16,20,0,0"Name="lhs"VerticalAlignment="Top"Width="80">leftoperand</Label><LabelHeight="31"HorizontalAlignment="Right"Margin="0,20,16,0"Name="rhs"VerticalAlignment="Top"Width="85">rightoperand</Label><TextBoxHeight="26"HorizontalAlignment="Left"Margin="16,57,0,0"Name="lhsOperand"VerticalAlignment="Top"Width="80"TextChanged="lhsOperand_TextChanged"/><TextBoxHeight="26"HorizontalAlignment="Right"Margin="0,55,21,0"Name="rhsOperand"VerticalAlignment="Top"Width="80"TextChanged="rhsOperand_TextChanged"/><StackPanelMargin="108,57,117,160.893333333333"Name="operators">红字的这两个表示触发文本的change事件,但是方法里内容为空啊,怎么理解
解决方案
解决方案二:
还没来得及写(或者没工夫写)呗。
解决方案三:
他想让你添加东西
解决方案四:
预置好了,让你自己写(或不写)
解决方案五:
让你自由发挥
解决方案六:
也有可能是手哆嗦了一下,双击了控件,自动生成的事件。根据你的业务需求,需要的话就补充完整。