Programming Overview Flashcards
Chapter 2
1
Q
How to create WPF application without XAML?
A
- Using Visual Studio, create a new project of type Console Application (not WPF
Application) - In the Solution Explorer, open the Properties window, and change Output Type to
Windows Application. - In the Solution Explorer, under References, look at the .NET tab, and add
references to the following assemblies:
− PresentationCore
− PresentationFramework
− WindowsBase - In the Program.cs file, do the following:
a. Add the [STAThread] attribute before the Main method declaration.
b. Add a using statement for System.Windows.
c. Create Window object
d. Create Application object
e. Use Run Method of the Application and pass it the Window object to run the program.
2
Q
Application and Window class relatshionship
A
Most minimally functional WPF programs contain an instance of the Application class and one or more instances of the Window class.
You can think of a WPF program as a single Application object and one or more Window objects:
- The Application object supports and hosts the Window objects.
- The Window objects comprise the user interface and present the data.
3
Q
The Window Class
A
Every window on the screen is the visual representation of an instance of the Window class.