Microsoft introduce the XAML language and XAML concepts to the Windows Store
app developer audience, and describe the different ways to declare
objects and set attributes in XAML as it is used for creating a Windows
Store app.
What is XAML?
Extensible Application Markup Language (XAML) is a declarative language.
Specifically, XAML can initialize objects and set properties of
objects, using a language structure that shows hierarchical
relationships between multiple objects, and using a backing type
convention that supports extension of types. You can create visible user
interface (UI)elements in the declarative XAML markup. You can then
associate a separate code-behind file for each XAML file that can
respond to events and manipulate the objects that you originally declare
in XAML. The XAML language supports interchange of sources between
different tools and roles in the development process without information
loss, such as exchanging XAML sources between Visual Studio and
Microsoft Expression Blend so that designer roles and developer roles
are separate and can iterate on the development of an app.
XAML files are XML files that generally have the .xaml file name extension.
Basic XAML Syntax :
XAML has a basic syntax that builds on XML, and by definition valid XAML
must be valid XML. But XAML also has syntax concepts that are assigned a
different and more complete meaning. For example, it supports property
element syntax, where property values can be set through elements rather
than strings.
Microsoft Visual Studio helps you to produce valid XAML syntax, both in
the XAML text editor and in the XAML design surface. So, don't worry too
much about the syntax with each keystroke. The IDE often helps you
write valid syntax via autocompletion, suggestions in Microsoft
IntelliSense lists, or other techniques. If this is your first
experience with XAML, it might still be useful to know the syntax rules
and particularly the terminology that is sometimes used to describe the
restrictions or choices.
XAML namespaces :
By a broad definition for programming, a namespace determines how
strings or identifiers that reference programming entities are
interpreted. A namespace can also resolve ambiguities if you reuse
identifiers. By using namespaces, a programming framework can separate
user-declared identifiers from framework-declared identifiers,
disambiguate identifiers through namespace qualifications, and so on. A
XAML namespace serves this purpose for the XAML language. Here's how
XAML applies and extends XML namespace concepts:
- XAML uses the reserved default-namespace XML attribute xmlns for namespace declarations, and the value of the attribute is a URI.
- XAML uses prefix declarations to declare non-default namespaces, and prefix usages in elements and attributes to reference that namespace.
- XAML has a concept of default namespace, which doesn't have to be the XML language default namespace.
- Namespace definitions inherit in an XML document from parent element to child element.
- Attributes of an element inherit the element's namespaces.
The XAML language XAML namespace :
One particular XAML namespace that is declared in nearly every Windows
Runtime XAML file is the XAML namespace for elements that are defined by
the XAML language. By convention, the XAML language XAML namespace is
mapped to the prefix "x". The default project and file templates for
Windows Store app projects always define both the default XAML namespace
(no prefix, just
xmlns=
) and the XAML language namespace (prefix "x") as part of the root element. For example, this snippet is a template-created Page root of the initial page for an app (showing the opening tag only, and simplified): <Page x:Class="Application1.BlankPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > </Page>
The "x" prefix/XAML language XAML namespace contains several programming
constructs that you use often in your XAML. Here are the most common
x: prefix/XAML namespace constructs:
No comments:
Post a Comment