我确定我忽略了一些简单的东西,但 WPF 不是我通常使用的东西,所以我对此有点摸不着头脑。我正在尝试为打算在后台运行的应用程序显示“启动画面”。它基本上是 Windows 操作系统的进程包装器。我有一个 WPFWindow定义如下:public partial class MainWindow : Window{ private Timer _timer; public MainWindow() { InitializeComponent(); ContentRendered += MainWindow_ContentRendered; } private void MainWindow_ContentRendered(object sender, EventArgs e) { _timer = new Timer(5000); _timer.Elapsed += TimerOnElapsed; _timer.Enabled = true; _timer.Start(); } private void TimerOnElapsed(object sender, ElapsedEventArgs e) { Dispatcher.Invoke(() => { Hide(); Close(); }); } ~MainWindow() { _timer.Dispose(); }}public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector { private bool _contentLoaded; /// <summary> /// InitializeComponent /// </summary> [System.Diagnostics.DebuggerNonUserCodeAttribute()] [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")] public void InitializeComponent() { if (_contentLoaded) { return; } _contentLoaded = true; System.Uri resourceLocater = new System.Uri("/MySolution.WindowsWrapper;component/mainwindow.xaml", System.UriKind.Relative); #line 1 "..\..\MainWindow.xaml" System.Windows.Application.LoadComponent(this, resourceLocater); #line default #line hidden }
1 回答
- 1 回答
- 0 关注
- 328 浏览
添加回答
举报
0/150
提交
取消