WpfBaseApp1 ( WPF )

Objectives:
  • In this example we intend to understand the functionality of an Application Class.
  • Using Application.Run
  •  window.Show();
    app.Run(window);
  • App.Xaml.cs : File does not contain any code to begin with. We can add codes that can be used for navigation purposes. The supporting events are listed below.
    • StartUp = In Application class, this method runs prior ( controto the loading the target page.
    • Exit 
    • Session ending
    • Activated = Occurs the first time you display the window. Note: This function won't work when published to a Web-Server.
    • Deactivated = when you switch from one window to another, the former is deactivated while the later is Activated
    • DispatcherUnhandlesException: Unhandled exception of the occurs anywhere on the application main thread.
  • Code : App.xaml.txt, MainWindow.xaml.txt, MainWindow.xaml.cs.txt,
Step:1 Create a New project

The Start-up Template may like the image shown  below. Mostly and by default, three Panes are displayed as we create new project.

Let us Save this Solution/Project as shown below

You save this application in a default folder selected by the Visual Studio 2010 Express application or can be saved elsewhere

Step:2 Creating a Base application type
  • Remove App.xaml and add another window item, name as StartUp.xaml as shown in the series of illustrations below.

Step:3 Manipulating MainWindow:

By default the class in the code-behind the XAML Design Script pane, is crated as a partial Class. This partial class inherits  another class Window as shown in the image below.

You may recreate App.xaml file using this code. The codes links up "MainWindow" with the Windows Base class libraries. App.xaml.txt

Edit the content of MainWindow following the steps shown below.

The link for the codes used in this pane ( MainWindow.xaml.cs.2.txt )

Step:4 Run time View