Working with Application Class or App.xaml file in WPF Application

Updated on     Kisan Patel

A WPF application whether it is standalone or XBAP, is represented by an instance of the Application class. This class provides some of the essential functionalities to configure and run WPF applications.

For instance, the Application class allows you to control the lifetime of a WPF application, work with command-line parameters and exit codes, handle events and run-time executions, and track the navigation of WPF applications.

Note that the Application class is available in both forms, the XAML code and .NET language code, using the App.xaml and App.xaml.cs files, respectively. In XAML, the <Application> tag or element signifies the application, while in the code-behind file; the App partial class does the same.

set-default-window-wpf-app

For Example, you can sets or returns the UI that is displayed when an application starts by specifying StartupUri property in App.xaml

<Application x:Class="WPFApp.App"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   StartupUri="MainWindow.xaml">
   <Application.Resources>

   </Application.Resources>
</Application>

WPF

Leave a Reply