御宇游,网王将错就错,三洋微波炉怎么样
原来的c#程序都有main的,现在用vs新建一个wpf项目,启动似乎变成app.xmal,前期项目中为了获取启动参数,很是折腾了一番:
1.先是修改app.xaml,添加startup事件
<application x:class="ykmain.app" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:ykmain" startup="application_startup">
2.然后编辑application_startup,判断e.args数组
private async void application_startup(object sender, startupeventargs e) { }
总感觉跟又臭又长的裹脚布一样,不爽。学习后,找回了传说中的main,莫有app.xaml,直截了当。
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(); } } }
ps:2020/3/3完善了一下
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); } } }
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Net Core Web Api项目与在NginX下发布的方法
asp.net core3.1 引用的元包dll版本兼容性问题解决方案
IdentityServer4实现.Net Core API接口权限认证(快速入门)
ASP.NET Core MVC通过IViewLocationExpander扩展视图搜索路径的实现
网友评论