Introducing the Application Object

As for Windows Forms, WPF also provides an Application class that allows interacting with your application instance. The class exposes several methods and properties that generally allow getting or assigning settings available within My Project. First, you need to get the instance of the running application. You accomplish this by assigning the Application.Current property to a variable as follows:

Dim myApp As Application = CType(Application.Current, Application)

When you get the instance of the application, you can get or set required information. The following code shows how you can retrieve the startup Uri (which corresponds to the startup object referred to a XAML file), the main application window, and ...

Get Visual Basic® 2010 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.