TextChanged方法里为空有什么作用

鱼塘一条大鱼鱼鱼yyy 2016-06-28 01:17:38
MainWindos.xaml文件代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;


namespace MathsOperators
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>

public partial class MainWindow : Window
{

public MainWindow()
{
InitializeComponent();
}

private void calculateClick(object sender, RoutedEventArgs e)
{
try
{
if ((bool)addition.IsChecked)
addValues();
else if ((bool)subtraction.IsChecked)
subtractValues();
else if ((bool)multiplication.IsChecked)
multiplyValues();
else if ((bool)division.IsChecked)
divideValues();
else if ((bool)remainder.IsChecked)
remainderValues();
}
catch (Exception caught)
{
expression.Text = "";
result.Text = caught.Message;
}
}

private void addValues()
{
int lhs = int.Parse(lhsOperand.Text);
int rhs = int.Parse(rhsOperand.Text);
int outcome;
outcome = lhs + rhs;
expression.Text = lhsOperand.Text + " + " + rhsOperand.Text;
result.Text = outcome.ToString();
}

private void subtractValues()
{
int lhs = int.Parse(lhsOperand.Text);
int rhs = int.Parse(rhsOperand.Text);
int outcome;
outcome = lhs - rhs;
expression.Text = lhsOperand.Text + " - " + rhsOperand.Text;
result.Text = outcome.ToString();
}

private void multiplyValues()
{
int lhs = int.Parse(lhsOperand.Text);
int rhs = int.Parse(rhsOperand.Text);
int outcome;
outcome = lhs * rhs;
expression.Text = lhsOperand.Text + " * " + rhsOperand.Text;
result.Text = outcome.ToString();
}

private void divideValues()
{
int lhs = int.Parse(lhsOperand.Text);
int rhs = int.Parse(rhsOperand.Text);
int outcome;
outcome = lhs / rhs;
expression.Text = lhsOperand.Text + " / " + rhsOperand.Text;
result.Text = outcome.ToString();
}

private void remainderValues()
{
int lhs = int.Parse(lhsOperand.Text);
int rhs = int.Parse(rhsOperand.Text);
int outcome;
outcome = lhs % rhs;
expression.Text = lhsOperand.Text + " % " + rhsOperand.Text;
result.Text = outcome.ToString();
}

private void quitClick(object sender, RoutedEventArgs e)
{
this.Close();
}

private void lhsOperand_TextChanged(object sender, TextChangedEventArgs e)
{

}

private void rhsOperand_TextChanged(object sender, TextChangedEventArgs e)
{

}
}
}




MainWindow.xaml.cs代码: Title="Maths Operators" Height="382" Width="367">
<Grid>
<Label Height="31.2766666666667" HorizontalAlignment="Left" Margin="16,20,0,0" Name="lhs" VerticalAlignment="Top" Width="80">left operand</Label>
<Label Height="31" HorizontalAlignment="Right" Margin="0,20,16,0" Name="rhs" VerticalAlignment="Top" Width="85">right operand</Label>
<TextBox Height="26" HorizontalAlignment="Left" Margin="16,57,0,0" Name="lhsOperand" VerticalAlignment="Top" Width="80" TextChanged="lhsOperand_TextChanged" />
<TextBox Height="26" HorizontalAlignment="Right" Margin="0,55,21,0" Name="rhsOperand" VerticalAlignment="Top" Width="80" TextChanged="rhsOperand_TextChanged" /> <StackPanel Margin="108,57,117,160.893333333333" Name="operators">
红字 的这两个表示触发文本的change事件,但是方法里内容为空啊,怎么理解
...全文
178 5 打赏 收藏 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
BitCoffee 2016-06-28
  • 打赏
  • 举报
回复
也有可能是手哆嗦了一下,双击了控件,自动生成的事件。根据你的业务需求,需要的话就补充完整。
  • 打赏
  • 举报
回复
让你自由发挥
xuzuning 2016-06-28
  • 打赏
  • 举报
回复
预置好了,让你自己写(或不写)
巴士上的邂逅 2016-06-28
  • 打赏
  • 举报
回复
他想让你添加东西
  • 打赏
  • 举报
回复
还没来得及写(或者没工夫写)呗。

111,128

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧