wpf学习笔记(2)《都是自己根据网络资源学习记录的仅供参考》

本文探讨了WPF应用程序启动过程中的关键事件处理方法,并详细介绍了如何通过这些事件进行程序初始化,包括窗口显示等操作。

今天早上一来打开昨天的wpf项目,从一个错误中发现了许多的新东西.
打开项目中的Debug文件夹(在vs下是隐藏的)可以发现App.g.cs和Window1.g.cs两个文件。
App.g.cs应该是程序的入口点文件。
Window1.g.cs有知道的解释下。谢谢了。

我们现在来看下App.xaml.cs这个类。这个类里包含了许多程序初始化的东西。
我们首先在类中增加下面代码:

         protected   override   void  OnStartup(StartupEventArgs e)
        
{
            
base.OnStartup(e);

            Window1 win 
= new Window1();
            win.Title 
= "MyApp";
            win.Show();
        }


运行会发现启动的时候出现了window窗体。
该方法是当程序启动的时候调用的方法。

总共有的方法如下:

Public eventActivated Occurs when an application becomes the foreground application.
Public event Deactivated Occurs when an application stops being the foreground application.
Public event DispatcherUnhandledException Occurs when an exception is raised by the application but not handled.
Public event Exit 程序退出时调用
Public event FragmentNavigation Occurs when a navigator in the application begins navigation to a content fragment, Navigation occurs immediately if the desired fragment is in the current content, or after the source XAML content has been loaded if the desired fragment is in different content.
Public event LoadCompleted Occurs when content that was navigated to by a navigator in the application has been loaded, parsed, and has begun rendering.
Public event Navigated Occurs when the content that is being navigated to by a navigator in the application has been found, although it may not have completed loading.
Public event Navigating Occurs when a new navigation is requested by a navigator in the application.
Public event NavigationFailed Occurs when an error is raised while a navigator in the application is navigating to the requested content.
Public event NavigationProgress Occurs periodically during a download that is being managed by a navigator in the application to provide navigation progress information.
Public event NavigationStopped Occurs when the StopLoading method of a navigator in the application is called, or when a new navigation is requested by a navigator while a current navigation is in progress.
Public event SessionEnding 当用户注销或者停止运行系统时终止session时调用
Public event Startup 程序启动时调用的方法 

本人英文翻译不好,其他的自己看吧。

Application = Code + Markup       -------    一个名人说的

本节结束。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值