今天早上一来打开昨天的wpf项目,从一个错误中发现了许多的新东西.
打开项目中的Debug文件夹(在vs下是隐藏的)可以发现App.g.cs和Window1.g.cs两个文件。
App.g.cs应该是程序的入口点文件。
Window1.g.cs有知道的解释下。谢谢了。
我们现在来看下App.xaml.cs这个类。这个类里包含了许多程序初始化的东西。
我们首先在类中增加下面代码:









运行会发现启动的时候出现了window窗体。
该方法是当程序启动的时候调用的方法。
总共有的方法如下:
![]() | Activated | Occurs when an application becomes the foreground application. |
![]() | Deactivated | Occurs when an application stops being the foreground application. |
![]() | DispatcherUnhandledException | Occurs when an exception is raised by the application but not handled. |
![]() | Exit | 程序退出时调用 |
![]() | 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. |
![]() | LoadCompleted | Occurs when content that was navigated to by a navigator in the application has been loaded, parsed, and has begun rendering. |
![]() | 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. |
![]() | Navigating | Occurs when a new navigation is requested by a navigator in the application. |
![]() | NavigationFailed | Occurs when an error is raised while a navigator in the application is navigating to the requested content. |
![]() | NavigationProgress | Occurs periodically during a download that is being managed by a navigator in the application to provide navigation progress information. |
![]() | 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. |
![]() | SessionEnding | 当用户注销或者停止运行系统时终止session时调用 |
![]() | Startup | 程序启动时调用的方法 |
本人英文翻译不好,其他的自己看吧。
Application = Code + Markup ------- 一个名人说的
本节结束。