C#WPF标签内容更改 [英] C# WPF Label content change

查看:226
本文介绍了C#WPF标签内容更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在为我的儿子创建用于数学练习的简单应用程序.我也是两周前开始练习C#的人.

Hi, I'm creating simple app for my son for math practice. It is also for me to practice C# as I started 2 weeks ago.

当重新生成新方程式时,Label没有用GOOD或WRONG更新时,我遇到了一个问题.

I got to a problem when Label is not updated with GOOD or WRONG before regenare new equation.

有人可以帮忙吗?

public MainWindow()
        {
            InitializeComponent();
            CHECK.IsEnabled = false;
        }
        public int check;
        public int number1;
        public int number2;
        public int correct;
        public int wrong;
        
        private void CHECK_Click(object sender, RoutedEventArgs e)
        {
            CHECK.IsEnabled = false;
            StartButton.IsEnabled = true;
            int suma = number1 + number2;
            if (Convert.ToInt32(input.Text) == suma)
            {
                num1.Content = "GOOD!";
            }
            else
            {
                num1.Content = "WRONG!";
            }
            Thread.Sleep(2000);
            input.Text = "";
            Numbers();
        }

        private void Numbers()
        {
            Random GetRandom = new Random();
            number1 = GetRandom.Next(1, 11);
            number2 = GetRandom.Next(1, number1);
            num1.Content = number1 + " + " + number2;
            StartButton.IsEnabled = false;
            CHECK.IsEnabled = true;
        }

        private void Start(object sender, RoutedEventArgs e)
        {

            Numbers();
            
        }
        


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

推荐答案

请尝试使用单词而不是 just 代码来描述问题.另外,请尝试将您发布的代码修剪为仅相关的部分.我了解有时不清楚要发布多少代码,但请尝试发布所有相关代码 但不超过所需的数量.但是,重要的是尝试使用单词尽可能地描述问题.

Please try to describe the problem using words instead of just code. Also, try to trim the code you post to just the relevant parts. I understand that it is sometimes not clear how much code to post but try to post all the relevant code but not more than what is necessary. The important thing however is to try to describe the problem as best as possible using words.


这篇关于C#WPF标签内容更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆