Learning WPF-learn about XAML in WPF and wpfxaml

Source: Internet
Author: User

Learning WPF-learn about XAML in WPF and wpfxaml
A brief description of XAML

XAML is used for instantiation.. NET object markup language, which is mainly used to build the WPF user interface. every element in the XAML is mapped. an instance of the. NET class. For example, the <Button> Button object mapped to wpf xaml can nest another element in one element. For example, the Grid element can nest the Button element.
 

Learn about XAML

Create a window in Visual Studio. The code generated by default is as follows:WindowUsed to describe a windowPageSimilar to Window, but it is used for applications that can be navigatedApplicationUsed to define application resources and startup settingsAny XAML document can have only one top-level element

Attribute

In the window tag, Title, Height, and Width are all window attributes. In The XAML file, the attribute value type is always a string, but the XAML parser can convert these strings to any. NET type.
 

Namespace

In the code above, the xmlns attribute is used to mark which namespace this document belongs to. Why does it need a namespace? If we define the Window class in a third-party component, if there is no namespace to limit it, the compiler does not know which Window type we will use to render the Window. In the code above, we can see two namespaces: the WPF core namespace and The XAML namespace.
 
 
WPF core namespace Bytes
XAML namespace Principal <x: ElementName>
With the namespace limitation, we can directly write the <Grid> label to map it to the System. Windows. Controls. Grid class.

Code hiding class

The user interface is created in XAML, but the interaction rules still need to be written in. NET language. The x: Class Attribute marks the. NET Class complex attributes that match the XAML file.

The value of some properties is not a simple type, but an object. The background color of the Grid below is not as good
  
  
Tag Extension

If we want to bind the property value to an existing object, we can use static tag to extend the additional property.

For nested elements, child elements can use some attributes defined by the parent element. These attributes are additional attributes in WPF and are mostly used for layout.
        
        
Modify record
: Complete all content
References
《Pro WPF 4.5 in C# 4th Edition》MSDN

Remarks

This article only briefly introduces the common knowledge of XAML, but also some uncommon knowledge. The advanced topic is not involved at the moment.

Related Article

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.