如果有几种方法可以在几秒钟之后使TextBlock不可见,或者即使TextBlock未在控制HUB内声明而看到不同的HubSection,也能告诉我吗?
答案 0 :(得分:0)
using System;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
Timer tmr;
public Form1()
{
InitializeComponent();
tmr = new Timer();
tmr.Interval = 3 * 1000; // 3 seconds
tmr.Tick += new EventHandler(tmr_Tick);
tmr.Start();
}
void tmr_Tick(object sender, EventArgs e)
{
label1.Visible = false;
tmr.Stop();
}
}
}
在WPF中,您可以使用DispatcherTimer执行相同的操作:
System.Windows.Threading.DispatcherTimer myDispatcherTimer = new System.Windows.Threading.DispatcherTimer();
myDispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 100); // 100 Milliseconds
myDispatcherTimer.Tick += new EventHandler(tmr_Tick);
myDispatcherTimer.Start();
public void tmr_Tick(object o, EventArgs sender)
{
myTextBlock.Text = "test";
}