要求:

文本框居中,用户不能修改运算结果 当用户选择不同的运算类型时 下方GroupBox的标题与所选运算类型相对应 且文本框数字立即清空 单击【计算】按钮时 如果文本框输入的内容非法 结果文本框显示问号

运行效果:

XAML:

后台代码:

 namespace A._2._2
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
} private void Btn_Click(object sender, RoutedEventArgs e)
{
if(!int.TryParse(tb1.Text,out int a) || !int.TryParse(tb2.Text,out int b))
{
tb3.Text = "?";
}else if (addbtn.IsChecked == true)
{
tb3.Text = int.Parse(tb1.Text) + int.Parse(tb2.Text)+"";
}
else if (subbtn.IsChecked == true)
{
tb3.Text = int.Parse(tb1.Text) - int.Parse(tb2.Text)+"";
}
else if (mulbtn.IsChecked == true)
{
tb3.Text = int.Parse(tb1.Text) * int.Parse(tb2.Text)+"";
}
else if (divbtn.IsChecked == true)
{
tb3.Text = int.Parse(tb1.Text) / int.Parse(tb2.Text)+"";
}
else if (delbtn.IsChecked == true)
{
tb3.Text = int.Parse(tb1.Text) % int.Parse(tb2.Text)+"";
}
} private void Radiobtn_Click(object sender, RoutedEventArgs e)
{
if (addbtn.IsChecked == true)
{
tbox.Text = "加法";
lb1.Content = "+";
tb1.Clear();
tb2.Clear();
tb3.Clear();
}
else if (subbtn.IsChecked == true)
{
tbox.Text = "减法";
lb1.Content = "-";
tb1.Clear();
tb2.Clear();
tb3.Clear();
}
else if (mulbtn.IsChecked == true)
{
tbox.Text = "乘法";
lb1.Content = "*";
tb1.Clear();
tb2.Clear();
tb3.Clear();
}
else if (divbtn.IsChecked == true)
{
tbox.Text = "除法";
lb1.Content = "/";
tb1.Clear();
tb2.Clear();
tb3.Clear();
}
else if (delbtn.IsChecked == true)
{
tbox.Text = "取模";
lb1.Content = "%";
tb1.Clear();
tb2.Clear();
tb3.Clear();
}
}
}
}

最新文章

  1. 新版微信h5视频自动播放
  2. arcgis对谷歌遥感影像拼接
  3. SQL图形化操作设置级联更新和删除
  4. Linux DHCP通过OPTION43为H3C的AP下发AC地址(总结)
  5. Web3D编程总结——3D碰撞检测初探
  6. 图文教您轻松学会用PS设计制作名片
  7. C# 中经常用到的HTTP请求类,已封装get,post,delete,put
  8. php_公共方法01_传入数组_打印可见信息
  9. 为outlook增加“邮件召回”功能
  10. ACdream 1007
  11. shell中的条件表达式
  12. hdu1256
  13. day05-(validate&amp;bootstred)
  14. Codeforces 781D Axel and Marston in Bitland 矩阵 bitset
  15. Docker 与 虚拟机比较
  16. es 基于match_phrase的模糊匹配原理及使用
  17. 解决linux下无线网卡被物理禁用问题
  18. 在SecureCRT中做make menuconfig乱码
  19. if判断比较详解
  20. JSP+Servlet+JavaBean实现数据库的增删改查

热门文章

  1. R 语言输入输出 读取命令函参数
  2. Spring系列(2):Spring框架
  3. 【转】gdb typeid 详解
  4. Net core学习系列(九)——Net Core配置
  5. 微信小程序调用微信支付接口
  6. Oracle JDBC prefetch: how to avoid running out of RAM
  7. grpc使用记录(二)简单同步服务实例
  8. 图片上传: ajax-formdata-upload
  9. git clone或者git clone时遇到gnutls_handshake() failed: An unexpected TLS packet was received.如何处理?
  10. groupby 的妙用(注意size和count)