Application類處於WPF應用程序的最頂端,main函數就在這個類中。
Application類的做用:
截圖鏈接 https://docs.microsoft.com/zh-cn/dotnet/api/system.windows.application?view=netframework-4.8
https://docs.microsoft.com/zh-cn/dotnet/framework/wpf/app-development/application-management-overviewc#
#region Assembly PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 // C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\PresentationFramework.dll #endregion using System.Collections; using System.Reflection; using System.Security; using System.Windows.Markup; using System.Windows.Navigation; using System.Windows.Resources; using System.Windows.Threading; namespace System.Windows { public class Application : DispatcherObject, IHaveResources, IQueryAmbient { [SecurityCritical] public Application(); public static Assembly ResourceAssembly { get; set; } public static Application Current { get; } public WindowCollection Windows { get; } public Window MainWindow { get; set; } public ShutdownMode ShutdownMode { get; set; } [Ambient] public ResourceDictionary Resources { get; set; } public Uri StartupUri { get; set; } public IDictionary Properties { get; } public event StartupEventHandler Startup; public event ExitEventHandler Exit; public event EventHandler Deactivated; public event SessionEndingCancelEventHandler SessionEnding; public event DispatcherUnhandledExceptionEventHandler DispatcherUnhandledException; public event NavigatingCancelEventHandler Navigating; public event NavigatedEventHandler Navigated; public event NavigationProgressEventHandler NavigationProgress; public event NavigationFailedEventHandler NavigationFailed; public event LoadCompletedEventHandler LoadCompleted; public event EventHandler Activated; public event NavigationStoppedEventHandler NavigationStopped; public event FragmentNavigationEventHandler FragmentNavigation; [SecurityCritical] public static StreamResourceInfo GetContentStream(Uri uriContent); public static string GetCookie(Uri uri); [SecurityCritical] public static StreamResourceInfo GetRemoteStream(Uri uriRemote); [SecurityCritical] public static StreamResourceInfo GetResourceStream(Uri uriResource); public static object LoadComponent(Uri resourceLocator); [SecurityCritical] public static void LoadComponent(object component, Uri resourceLocator); public static void SetCookie(Uri uri, string value); public object FindResource(object resourceKey); [SecurityCritical] public int Run(Window window); public int Run(); public void Shutdown(); [SecurityCritical] public void Shutdown(int exitCode); public object TryFindResource(object resourceKey); protected virtual void OnActivated(EventArgs e); protected virtual void OnDeactivated(EventArgs e); protected virtual void OnExit(ExitEventArgs e); protected virtual void OnFragmentNavigation(FragmentNavigationEventArgs e); protected virtual void OnLoadCompleted(NavigationEventArgs e); protected virtual void OnNavigated(NavigationEventArgs e); protected virtual void OnNavigating(NavigatingCancelEventArgs e); protected virtual void OnNavigationFailed(NavigationFailedEventArgs e); protected virtual void OnNavigationProgress(NavigationProgressEventArgs e); protected virtual void OnNavigationStopped(NavigationEventArgs e); protected virtual void OnSessionEnding(SessionEndingCancelEventArgs e); protected virtual void OnStartup(StartupEventArgs e); } }
在xml文件中指定啓動的Page或者Windows就可啓動窗體。
windows