WPF的Application.Startup事件
我打算将特定的扩展名关联到自己写的WPF程序,通过双击该类型文件,然后打开该文件,我查了一下MSDN,在App.xaml里面加入
Startup="App_Startup"
然后我的App.xaml.cs是这样写的
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
namespace ChineseChess
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
void App_Startup(object sender, StartupEventArgs e)
{
if (e.Args.Length == 1)
{
MessageBox.Show(e.Args[0]);
}
MainWindow mainWindow = new MainWindow();
mainWindow.Show();
}
}
}