Resource

Application MainWindow in WPF

XAML Designer Resources Oct 25, 2009
MainWindow property gets or sets the main window of the application. The code snippet in Listing 4 gets the MainWindow.
  • 0
  • 0
  • 19058

MainWindow property gets or sets the main window of the application. The code snippet in Listing 4 gets the MainWindow.

Application curApp = Application.Current;
Window mainWnd = curApp.MainWindow;

Listing 4

The code snippet in Listing 5 sets MainWindow property in XAML.

<Application x:Class="WPFSample.App"

             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

             StartupUri="Window1.xaml"

             Startup="App_Startup">

    <Application.MainWindow>

        <NavigationWindow Source="Window1.xaml" Visibility="Visible">
        </
NavigationWindow>

    </Application.MainWindow>
</
Application>

Listing 5

COMMENT USING

PREMIUM SPONSORS

Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.

TOP RESOURCES

MOST LIKED RESOURCES