ArticleDirectory
- What is XAML: basic controls (How does XAML represent a control)
- Namespace
What is the basis of XAML? XAML: basic controls (How does XAML represent a control)
Use button as an example to describe XAML
<Button tag = "I Am a button" content = "I Am a button" cursor = "eraser" Click = "button_click" padding = "5" margin = "5"/>
Namespace
According to the Conventions, the XAML namespace is mapped to the prefix X :.
The default project and file template of the Silverlight project always have the default XAML namespace (no prefix, only xmlns =) at the same time) and the XAML language namespace (mapped to the prefix x :) is defined as part of the root element.
Example:CodeSegment is the Silverlight ApplicationProgramThe usercontrol root created by the template on the initial Page (only the start tag is displayed and simplified ):
<Usercontrol
Xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"
...>
X: the prefix/XAML Language XAML namespace contains multiple programming structures that will be frequently used in Silverlight XAML.
The most common X: prefix/XAML namespace structure is listed below:
X: Key
Set a unique user-defined key for each resource in resourcedictionary. The key tag string is used as a staticresource tag extension parameter to retrieve any of these resources from another XAML usage.
X: Class
Specify the CLR namespace and Class Name of the class that provides code hiding for the XAML page, and name the class created or linked in the Silverlight application model by generating the markup compiler operation. You must have such a class to support code hiding or initialization as rootvisual. For these reasons, you almost always see X: ing, even if there is no resource and you never use X: Name is no exception.
X: Name
After processing the object elements defined in XAML, specify the runtime object name for instances in the runtime code.