wpf模拟弹出窗口的代码,模拟加载时,弹出提示信息 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;
namespace WpfApplication4
{
/// <summary>
/// Window2.xaml 的交互逻辑
/// </summary>
public partial class Window2 : Window
{
long _start;
DispatcherTimer timer;
DispatcherTimer _closetime;
public Window2()
{
InitializeComponent();
timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromMilliseconds(1);
_start = Environment.TickCount;
timer.Tick = timer_Tick;
timer.IsEnabled = true;
this.Left = SystemParameters.WorkArea.Width - this.Width;
this.EndTop = SystemParameters.WorkArea.Height - this.Height;
this.Top = SystemParameters.WorkArea.Height;
}
void _closetime_Tick(object sender, EventArgs e)
{
this.Close();
}
public double EndTop { get; set; }
void timer_Tick(object sender, EventArgs e)
{
while (this.Top > EndTop)
{
this.Top -= 0.1;
}
_closetime = new DispatcherTimer();
_closetime.Interval = TimeSpan.FromMilliseconds(10000);
_closetime.Tick = _closetime_Tick;
_closetime.IsEnabled = true;
}
private void Window_Loaded_1(object sender, RoutedEventArgs e)
{
timer.Start();
}
}
}
评论