WPF 手机验证码 发送按钮倒计时 代码

        private async void SendButton_Click(object sender, RoutedEventArgs e)
        {
            var button = sender as Button;
            var text = button.Content.ToString();
            if (SendVerifyCodeCommand?.CanExecute(null) == true)
            {
                SendVerifyCodeCommand?.Execute(null);
            }
            button.IsEnabled = false;
            for (int i = 90 - 1; i >= 0; i--)
            {
                button.Content = $"{i} s";
                await Task.Delay(TimeSpan.FromSeconds(1));
            }
            button.IsEnabled = true;
            button.Content = text;
        }
原文地址:https://www.cnblogs.com/lopengye/p/7070612.html