Introduction to XAML files

Source: Internet
Author: User
Tags silverlight

1. Concept of XAML:

The XAML language is short for the Extensible Application Markup Language. The English pronunciation is zammel. The Chinese language is called the Extensible Application Markup Language. The language is based on the extensive markup language (XML) extensible markup language, it is mainly used for Silverlight, WPF, Windows Phone, and Windows 8 application development.

2. XAML objects and attributes:

A. Introduction to objects:

In XAML code, an element is usually an object, which is mapped to the corresponding element in the code.. Net class. The XAML Code declares an element object, which must be composed of a start tag "<Element Object>" and an end tag "</Element Object>. The basic syntax is as follows: <Element Object> </Element Object>

For example, declare a textbox object in XAML. The Code is as follows:<Textbox> </textbox>

 Note: In the XAML Syntax of Windows 8 and Silverlight, the scaled element end tag is supported. The syntax format is as follows:<Textbox/>In XAML, elements (element) and attributes (feature) names are case-sensitive and case-sensitive.

 B. Introduction to attributes:

The attribute mentioned here is related to the object. An object corresponds to multiple attributes, such as a text box corresponding to attributes such as the background color, width, and height.

 

The three methods for setting object attributes in XAML are::

1. set object attributes using the attribute feature (you can use attributes (feature) to define attributes of one or more object elements after the Object Name of the start tag. This method is "inline attribute ");

The basic syntax is:<Element Object Property name = "property value" property name = "property value"...> </Element Object>

Example:

2. Set object properties through the property element (supports compound controls or custom controls to reference complex object properties to achieve special effects). The basic syntax is: <Element Object> <Element Object. Attribute> <Property setter property value = ""> </Element Object. Attribute> </Element Object>For example, the running effect is: 3. Set object attributes through implicit dataset (attribute values can be a dataset). For example, assign values to a ComboBox combo box in XAML. The traditional code is as follows: <ComboBox>
<ComboBox. Items>
<Comboboxitem content = "First Grade"/>
<Comboboxitem content = "Grade 2"/>
<Comboboxitem content = "Grade 3"/>
</ComboBox. Items>
</ComboBox> use the implicit dataset to set object attributes. You can modify the preceding code to <ComboBox Height = "42" horizontalalignment = "Left" margin = "58,76, 169 "name =" combox1 "verticalignment =" TOP "width =" ">
<Comboboxitem content = "First Grade"/>
<Comboboxitem content = "Grade 2"/>
<Comboboxitem content = "Grade 3"/>
</ComboBox>

 

Introduction to XAML files

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.