Floating FB sharing byReview Results

Floating FB sharing byReview Results

  • WPF Tutorial

    • # Read in Your Language

    WPF Fundamentals

    Tutorial Home | Base classes for WPF | WPF LifeCycle

    WPF Application LifeCycle

    WPF Application:

    WPF Application when started, application object is created.

    Run method fires Applicaton.Startup event and shows main window.
            static void Main()
            {	Application app = new Application();
    	        Window1 win = new Window1();

    WPF uses application model by deriving Applicaton class:

             <Application x:Class="TestApplication.App"
    public partial class App : Application { [STAThread()] public static void Main() { TestApplication.App app = new TestApplication.App(); app.InitializeComponent(); app.Run(); } public void InitializeComponent() { this.StartupUri = new Uri("Window1.xaml", System.UriKind.Relative); }
    See in App.g.cs file in the obj\Debug folder inside project directory.

    Application Level Events :

    Startup : Occurs after the Application.Run() method is called and just before the main window is shown

    Exit : Occurs when the application is being shut down Use the Exit event to set the integer exit code .

    Deactivated :Occurs when a window in the application is deactivated.

    Occurs when an unhandled exception is generated anywhere in your application ( On main thread)

    Splash Screen:


    1. Add an image file to your project. (Typically, this is a .bmp, .png, or .jpg.)

    2. Select the file in the Solution Explorer.

    3. Change the Build Action to SplashScreen.

    When you run application, this graphic will be shown immediately, in the center of the screen, Once the runtime environment is ready, and after the Application_Startup method has finished,

    Application’s first window appears, and the splash screen graphic fades away quickly (in about 300 milliseconds).

    Command Line arguments (Accept any text file name and load ):

                public partial class App : Application
                private static void App_Startup(object sender, StartupEventArgs e)
                FileViewer win = new FileViewer();
                if (e.Args.Length > 0) {string file = e.Args[0];
                if (System.IO.File.Exists(file))
    	        // (Perform alternate initialization here when
    	        // no command-line arguments are supplied.)
                // This window will automatically be set as the
                // Application.MainWindow.
                win.Show(); }
    //Acccessing from FileViewer public partial class FileViewer : Window { ... public void LoadFile(string path) { this.Content = File.ReadAllText(path); this.Title = path; } }

    << Previous >> | << Next Topic>>