Instantiating Windows at Runtime

Creating and displaying windows at runtime is a common task in every client application. To do this, you create an instance of a System.Windows.Window and then invoke the Show or ShowDialog methods, depending on whether the Window must be considered a modal dialog box. The following Visual Basic code demonstrates how you create and show a new Window:

Dim aWindow As New Window'Set your Window properties here...aWindow.ShowDialog()'....aWindow.Close()

In the preceding code, a new Window is generated from scratch, so this requires specifying all properties. In most cases you can instead create and show instances of existing windows that you implemented at design time; for this, in the ...

Get Visual Basic 2015 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.