What Is a Markup Language?
Markup language is a computer text encoding that combines text and other text-related information to reveal details about document structure and data processing. Other text-related information (including the structure and presentation information of the text) is combined with the original text, but is identified using tags.
- Markup languages can generally be divided into three categories: identifying, procedural, and descriptive. [1]
- Markup language, which uses a series of agreed-upon tags to mark electronic documents to achieve the definition of the semantics, structure, and format of electronic documents. These tags must be easily distinguishable from the content and easily identifiable. The development of markup languages is as follows:
- The markup language widely used today is
- XAML (ExtensibleApplicationMarkupLanguage), based on XML, is used in Microsoft WPF (WindowsPresentationFoundation).
- XAML provides a syntax that is easy to extend and locate to define a user interface that is separate from program logic, and this implementation is very similar to the "code behind" model in ASP.NET. XAML is a parsing language, although it can also be compiled. It has the advantage of simplifying the programmatic user creation process and adding code when applying.
- Open a XAML file with a text editor, and you will find that a XAML file has only one element as the root, and this root is the object graph of the entire runtime of the application. Under this root, there are 3 ways to declare objects to build a meaningful XAML file. Next introduce the structure and objects of the XAML file:
- 1. Use object element syntax directly
- If objectName is a type name that needs to be instantiated, wonder if you can create the object with the following code:
- <objectName>
- </ objectName>
- Generally an object also includes other objects, then it can be expressed as follows:
- <objectName>
<otherobjectName>
- </ otherobjectName>
</ objectName>
- For convenience, it can be omitted as follows:
- <objectName>
<otherobjectName />
- </ objectName>
- 2. Set attributes using attribute syntax
- If objectName is the object to be instantiated, propertyName is the name of the property to be set, and propertyValue is the value of the property to be set. Then the code that should be used is as follows:
- <objectName propertyName = "propertyValue" ... />
- or:
- <objectName propertyName = "propertyValue">
... <-element children->
</ objectName>
- 3. Mark extension
- Markup extension is a XAML attribute syntax that uses curly braces ({and}) to represent markup extensions. This method can be said that the attribute value is not just regarded as a character or text, the analyzer will call the code applicable to the specific markup extension to construct the object in the markup.
- This method is widely used for data binding, such as:
- <Grid x>: Name = "LayoutRoot" Background = "White">
<ComboBox ItemsSource = "{Binding ElementName = LayoutRoot}" />
</ Grid>
- The above code binds the value of the Itemssource property of the ComboBox to Layoutroot. [4]