WPF architecture Flashcards

Chapter 3

1
Q

Source Code Generated by the Visual Studio Template

A
  • Two of the files implement class App⎯one XAML file and one C# file.
  • The other two files implement class MainWindow⎯one XAML file and one C# file.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

XAML Logical Trees and Visual Trees

A

• The logical tree comprises the elements as they are listed in the XAML. These include panels and controls you will generally use.
• The visual tree includes the parts that make up the controls and panels. You don’t generally have to deal with these. But you need to be aware of the visual tree
because it’s referred to in the literature, and you also might need to deal with it if you need to do some more advanced tinkering.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

XAML Compilation Process

A

For a program using both XAML and C#, the compilation is a two-step process. In the first step, the compiler takes each XAML file and translates it into two files:

  • generated C# file: MainWindow.g.cs
  • Condensed binary XAML file MainWindow.baml

In the second step, the compiler takes the C# files and the BAML files and produces the
executable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

XAML Compilation - how are files used

A

The compiler takes the C# source file and the generated C# file, and uses the partial classes in
each to create the complete class.

The generated C# file has the InitializeComponent method, which loads the UI tree and connects all the pieces and event handlers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

WPF brush types

A

• A SolidColorBrush paints the surface using a single color.
• A GradientBrush starts its stroke painting one color and transitions to another color by the end of the stroke. There are two types of gradient brush— LinearGradientBrush and RadialGradientBrush.
• A TileBrush paints an area with an image. There are three kinds of TileBrushes, which differ in the types of image used. They are ImageBrush, DrawingBrush, and
VisualBrush.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

WPF Brushes and Colors static classes

A
WPF provides a class called Brushes that can supply SolidColorBrush objects of 141 predefined
colors. 
WPF framework supplies a
class called Colors, which defines 141 common colors. This class is similar to the Brushes class you saw
previously. But instead of returning SolidColorBrush objects, it returns Color objects.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

The Application Class

A

The Application class starts your program running and manages the messages that drive it.
• The Run method starts the program running and calls the OnStartup method,
which will be described later in this chapter.
• The Current property is a static property that returns a reference to the program’s
Application object.
• The ShutdownMode property can hold one of three values of the ShutdownMode
enumeration. The value specifies the condition on which the application should
be shut down. The enumeration values are the following.
− OnLastWindowClose: The application closes when its last window closes.
− OnMainWindowClose: The application closes when its main window closes.
− OnExplicitShutdown: The application closes only when its Shutdown method is
called.
• The StartupUri property holds the location of the UI to start when the application
starts.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

WPF Application Lifetime Events

A

• Startup is raised by the Run method when the application is first starting up.
• Exit is raised when the application is closing down.
• Activated is raised when the application becomes the foreground application.
• Deactivated is raised when a different application becomes the foreground
application.
• SessionEnding is raised when the Windows session is ending. This usually means
the computer is shutting down.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

UI Elements Contain Content

A

• The Content property can contain a single item of content.
− Controls derived from the ContentControl class inherit this property.
− Notice from the figure that both the Window class and the Button class are derived from ContentControl. A button can contain the same types of content
as a window.
• The Items property is a collection that can contain multiple items of content.
− Controls derived from the ItemsControl class inherit this property.
− An example is the Listbox control, which uses the Items property to hold the
items displayed in the list box.
• The Children property is also a collection of UI elements. The Children property is
inherited by classes derived from the Panel class.
• The HeaderedItemControl class is unusual in that it contains a reference to a single
item of content, as well as a collection of items.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

The Class Inheritance Hierarchy

A

For most purposes, you will use the classes in the PresentationFramework assembly that follows the hieararchy FrameworkElement, UIElement, and Visual.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly