[Wpf学习] 1.传说中的Main
2021-03-10 01:29
标签:static sof ash 获取 false mic 启动 round temp 原来的C#程序都有Main的,现在用vs新建一个Wpf项目,启动似乎变成App.xmal,前期项目中为了获取启动参数,很是折腾了一番: 1.先是修改App.xaml,添加StartUp事件 2.然后编辑Application_Startup,判断e.Args数组 总感觉跟又臭又长的裹脚布一样,不爽。学习后,找回了传说中的Main,莫有App.Xaml,直截了当。 PS:2020/3/3完善了一下 [Wpf学习] 1.传说中的Main 标签:static sof ash 获取 false mic 启动 round temp 原文地址:https://www.cnblogs.com/etoumao/p/12717387.html
private async void Application_Startup(object sender, StartupEventArgs e)
{
}
using System;
using System.Windows;
namespace L1_NoXaml
{
public class Program : Application
{
[STAThread]
static void Main(string[] args)
{
Program app = new Program();
app.MainWindow = new Window1();
app.MainWindow.ShowDialog();
}
}
}
using System;
using System.Windows;
namespace YKMainCore
{
public class Program : Application
{
[STAThread]
static void Main(string[] args)
{
SplashScreen splashScreen = new SplashScreen("id.png");
splashScreen.Show(true);
MainWindow window = new MainWindow()
{
WindowStyle = WindowStyle.None,
ResizeMode = ResizeMode.NoResize,
WindowState = WindowState.Normal,
ShowInTaskbar = false,
Background = System.Windows.Media.Brushes.Transparent,
AllowsTransparency = true,
Left = 0,
Top = 0,
Width = SystemParameters.PrimaryScreenWidth,
Height = SystemParameters.PrimaryScreenHeight
};
Program app = new Program();
app.Run(window);
}
}
}
上一篇:window事件
文章标题:[Wpf学习] 1.传说中的Main
文章链接:http://soscw.com/index.php/essay/62546.html