using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Threading;
namespace SilverlightApplication39
{
public partial class MainPage : UserControl
{
private Button TestButton = null;
private DispatcherTimer timer = null;
public MainPage()
{
InitializeComponent();
TestButton = new Button();
TestButton.Width = 200;
TestButton.Height = 24;
TestButton.Content = "Test";
TestButton.Click += new RoutedEventHandler(TestButton_Click);
LayoutRoot.Children.Add(TestButton);
timer = new DispatcherTimer();
timer.Interval = new TimeSpan(0, 0, 2);
timer.Tick += new EventHandler(timer_Tick);
}
void timer_Tick(object sender, EventArgs e)
{
TestButton.IsEnabled = true;
}
void TestButton_Click(object sender, RoutedEventArgs e)
{
TestButton.IsEnabled = false;
timer.Start();
}
}
}silverlight DispatcherTimer 使按钮在指定的时间内不可编辑
最新推荐文章于 2025-08-07 16:35:05 发布
本文介绍了一个使用Silverlight实现的简单应用程序,该程序通过按钮触发一个计时器,计时结束后按钮重新变为可用状态。文章详细展示了如何创建按钮并设置其属性,以及如何使用DispatcherTimer进行计时。
1067

被折叠的 条评论
为什么被折叠?



