
XAML-specific Elements and Attributes
Strictly speaking, XML-based grammars do not support true keywords. However, XML parsers can be
programmed to look for special tokens that will be treated in a special, customized manner. The same is true
for XAML as it defines a number of tokens that can be regarded as ‘keywords’ in a general sense. Many of
these are used to control how the XAML markup is processed at compile time via msbuild.exe.
Because these XAML-specific tokens are part of the XAML namespace, many of them must take an x:
prefix (x:Name, x:Code, x:Class, and so forth). As you will see, as a convenience, some tokens such as Name
do not require an x: prefix.
As you have seen earlier in this chapter, the x:Class and x:Code tokens are XAML tokens. A Window or
Application can specify an x:Class attribute in its opening definition and is used to define the name of the
class type in the code files. The <x:Code> XAML element can be used to embed code within a XAML file.
Here is a <Window> element that defines the x:Class attribute:
<!-- The x:Class attribute will be used by msbuild.exe to
Define a C# or VB class type to represent the
code of this XAML. -->
<Window x:Class = "MyWPFApp.MainWindow"
xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x = "http://schemas.microsoft.com/winfx/2006/xaml">
</Window>
XAML-specific Elements and Attributes
Table of Contents
Copyright (c) 2008. Intertech, Inc. All Rights Reserved. This information is to be used exclusively as an
online learning aid. Any attempts to copy, reproduce, or use for training is strictly prohibited.
Courseware
Training Resources
Tutorials
XAML Keyword
|
Meaning in Life
|
Array
|
Used to represent a .NET array type in XAML.
|
ClassModifier
|
Allows you to define the visibility of the class type (internal or public) denoted by the Class keyword.
|
DynamicResource
|
Allows you to make reference to a WPF resource that should be monitored for changes.
|
FieldModifier
|
Allows you to define the visibility of a type member (internal, public, private, protected) for any named sub-element of the root (e.g., a <Button> within a <Window> element).
|
Key
|
Allows you to establish a key value for a XAML item that will be placed into a resource dictionary.
|
Name
|
This allows you to specify the generated C# name of a given XAML element.
|
Null
|
Represents a null reference.
|
Static
|
Allows you to make reference to a static member of a type.
|
StaticResource
|
Allows you to make reference to a WPF resource that should not be monitored for changes.
|
Type
|
This is the XAML equivalent of the C# typeof operator / VB GetType operator. It will yield a System.Type based on the supplied name.
|
|
Services