WpfAppType2 ( WPF )

Objectives:
  • Using Startup Method.
  • Distinction  between Startup and StarupURI
    • StartupUri in App.xaml, will load a window declaratively from a URI.
    • If you need access to the main window during startup, you need to manually create a new window object from your Startup event handler.
  • Static

    a) default

    b) Application.Resources

    c) Choosing Static Windows background

Application is a class that encapsulates WPF application-specific functionality, including the following:

•Application Lifetime Related : Activated, Current, Deactivated, DispatcherUnhandledException, Exit, Run, SessionEnding, Shutdown, ShutdownMode, Startup.

•Application-Scope like Window, Property, and Resource Management: FindResource, GetContentStream, GetResourceStream, LoadComponent, MainWindow, Properties, Resources, StartupUri, Windows.

•Command-Line Parameter and Exit Code Processing: Application.Startup, Application.Exit, Application.Shutdown.

•Navigation: FragmentNavigation, LoadCompleted, Navigated, Navigating, NavigationProgress, NavigationStopped, NavigationFailed, SetCookie, GetCookie.

 

Step:1 Create a New project

Project Created by default, contains "WPF -Windows-Application", which is very similar to "Windows Form Application" . This Template also provide few other flavors, and we we going to explore one at a time`. To date, WPF-Windows-Application  is a fare alternate choice to  the classical Windows-Form-Application , with XAML coding and conventional coding which marks it's separation from windows-form-application.

Code-Behind-MainWindow

App.xaml: Reference point of application resources.

Code behind of App.xmal

Step:2 Life and regulation of Window and it's options. You may convert into a Navigational or Page Application type.

Step:3 Edit Code in

a) App.xaml: App.xaml.1.txt to App.xaml.2.txt

b) Edit App.xaml.cs

Step:4 Runtime Views

a) App_StartUp

Window is displayed

Since two "Message-Boxes" in "App_Startup" padded the object created from "MainWindow", the cursor returns to the Application Pane-Module and displays the second message.

b) The events involved in Closing "MainWindow". First the local object will tend to close and

The illustration below shows how the cursor shifts   from "MainWindow" to "Application Class". 

 

 

 

Step:5 Notes:
Application is a class that encapsulates WPF application-specific functionality, including the following:

Application implements the singleton pattern to provide shared access to its window, property, and resource scope services. Consequently, only one instance of the Application class can be created per AppDomain.

You can implement an Application using markup, markup and code-behind, or code. If Application is implemented with markup, whether markup or markup and code-behind, the markup file must be configured as an Microsoft build engine (MSBuild) ApplicationDefinition item.

NoteNote