This example demonstrates several useful XAML techniques.
First, this is a loose XAML page. It uses a Page element as its root rather than a Window because the Window class requires extra permissions on the client computer.
Attributes on the Page set the Page's FontFamily and FontSize. These are inherited by controls contained in the Page unless they are overridden in those controls.
The Page's Resources section stores resourcs for the Page. In this example, that includes a Style for Image controls and a Style for Label controls. The Styles use Setters to define properties that should be set for those controls.
Note that some properties cannot be set in a loose XAML page. For example, BitmapEffects are implemented in unmanaged code, which requires extra permissions so is not allowed in a loose XAML page.
Note also that the Page would not accept a FontWeight attribute, although the Label control's Style did so I set it in that Style.
The Page's Background property defines the Page's background brush. In this case, it is a linear gradient brush shading from light blue at the top to dark blue at the bottom.
Finally the Page contains a StackPanel oriented horizontally. That contains a series of StackPanels oriented vertically, each containing an Image and a Label. Note that the JPEG files must be in the same location as the XAML file.
The Image and Label controls set their Style properties to the Styles previously created in the Page's resources. Those Styles set the controls' HorizontalAlignment properties to Center so the images and text are centered in their entries in their StackPanels.
|