[Reprint] (idle talk WPF)

Source: Internet
Author: User
Tags element groups xsl xslt

Http://www.cnblogs.com/YilingLai/archive/2006/12/21/598965.html

About WPF

Windows Presentation Foundation (WPF) is one of the three core development libraries of Microsoft's new Vista operating system. It is mainly responsible for graphic display, so it is called presentation ).
As a new graphics engine, WPF is based on DirectX. Of course, many new features are added.

Idle Talk: One of WPF (the structure of WPF)

WPF can be considered to be the product of MS that utilizes some of the features of the original. NET Framework, coupled with dirextx. From the WPF component, we can see that the bottom layer is still some kernel APIs.

 

The red component is the core of WPF. Milcore is an unmanaged component that interacts with DirectX. the unmanaged code can provide us with more efficient processing and better interaction with dirextx. All displays of WPF are completed by dirext. One of the most important functions of milcore is the composition engine, which requires high efficiency. Its specific functions will be introduced later. Therefore, milcore gave up some CLR features in exchange for efficiency. The other two red components are built on the CLR and take advantage of. net.

As for the role of the USER32 component, I know that USER32 is required for some compatibility in some WPF application scenarios, where DWM (desktop window management) is available ).

In addition to the basic structure of WPF, what is more important is what functions WPF provides. *** it means that WPF can process almost all media types: bitmap, 3D, audio, video, and text. Using WPF, it integrates the current GDI/GDI +, d3d/OpenGL, and multimedia dshow. All things are equivalent objects, regardless of 3D, 2d, or text.

The animate block in the structure diagram runs through the entire structure, because in WPF, We Can animation all the visible content. This is a very promising feature. The composition engine is located in the milcore component. During the development process, we have a variety of Interface Element functions, such as video and video. The content displayed in the window can be considered as just an image (accurate to surface ). The function of this engine is to merge these image and video elements for final submission and display.

Idle talk wpf ii (XAML overview)

XAML separates the UI code from the logic code of the application. In. Net 3.0 and Windows Vista, XAML and WPF build the entire UI together. Since XAML is based on XML, every XAML code must be a complete XML file. XAML inherits all XML definitions and rules. The difference between XAML and other XML extensions is what it means. Each XAML element is a. Net CLR class. XML makes it easy for us to extend and operate XAML. Using the relationship of WPF in XAML, developers can independently design beautiful UIS, and perhaps more beautiful unions will emerge. We can write the program logic in a separate file or embed it in an XML file inline.

There should be three XML functions that are most used in XAML: namespaces, attributes, and child elements.

In addition to the advantages of markup language and XML, XAML also has the following advantages:

Designing the UI with XAML is simpler

XAML requires less encoding than other uidesign techniques.

The UI designed by XAML facilitates transfer and submission in other environments. For example, in web or Windows client.

It is very easy to design a dynamic UI with XAML

XAML brings a new revolution to the uidesigner. Now, all designers no longer need the. NET development knowledge to design the UI. In the near future, end users will be able to see more beautiful UIS.

As mentioned above, each XAML element represents a. Net CLR class. Most XAML elements are inherited from system. Windows. uielement, system. Windows. frameworkelement, system. Windows. frameworkcontentelement, and system. Windows. contentelement. No XAML element corresponds to the. net clr abstract class. However, many elements correspond to a derived class of an abstract class.

 

There are usually four generic XAML elements:

Root element: Windows and page are the most common root elements. These elements are located in the root element of the XAML file and contain other elements.

Panel element: helps you set the UI position. Stackpanel, dockpanel, grid, and canvas are commonly used.

Control Element: defines the control type of The XAML file. Allows you to add and customize controls.
Document element: Helps document submission. It is mainly divided into inline and block element groups to help design similar documents. Some famous inline elements include bold, linebreak, and italic. The block elements include paragraph, list, block, figure, and table.

The property of a XAML element is similar to that of a. Net object. The object-oriented feature of XAML makes its behavior similar to that of a previous HTML object. Each attribute (actually a class attribute) inherits the attribute or overload of the parent element (if the attribute is reset ).

1. Introduction to XSLT
XSLT is a language used to convert XML documents into XHTML documents or other XML documents.
XPath is a language used for navigation in XML documents. XPath is a W3C standard.
XSLT refers to XSL Transformation (XSL transformations ). XSLT is the most important part of XSL.
XSLT uses XPath for navigation in XML documents.
XSLT is used to convert an XML document to another XML document, or other types of documents that can be recognized by the browser, such as HTML and XHTML. Generally, XSLT converts Each XML element into an (x) HTML element to complete this task.
With XSLT, you can add or remove elements and attributes to or from an output file. You can also rearrange elements, perform tests, and decide which elements to hide or display.
A common description of the conversion process is that XSLT converts the XML source tree to the XML result tree.

XSLT uses XPath to search for information in XML documents. XPath is used to navigate the XML document through elements and attributes.
How does it work?
During the conversion process, XSLT uses XPath to define the parts of the source document that can match one or more predefined templates. Once the matching is found, XSLT converts the matching part of the source document to the result document.
XSLT is W3C Standard
XSLT was established as W3C standard in November 16, 1999.
2. XSLT Browser
Almost all major browsers support XML and XSLT.

XAML
XAML is the abbreviation of Extensible Application Markup Language, it is a new descriptive language that Microsoft has created to build an application user interface. XAML provides a syntax for extension and positioning to define a user interface separated from program logic. This implementation method is similar to the "Code Post" Model in ASP. NET. That is to say, when developing an application, we can divide the development work into two groups: developers and designers, responsible for the background program code logic and front-end program interface design, in this way, the collaboration between developers and designers is more smooth, and their expertise is greatly utilized.

WPF-nature: Data and Behavior

If we build a UI framework by ourselves, what aspects will we focus on first? I think the UI framework must process two levels of content: data presentation and data operations, therefore, the UI framework must be able to receive different types of data and display the data through the UI interface, and then operate the data through the control behavior, that is, the data of the UI framework) and behavior (behavior ).

This article explains how to process and operate data in WPF. After reading this article, you should have a preliminary understanding of how the WPF framework converts data into a display interface. This is also one of the core designs of WPF.
Data)

The controls in the previous UI framework have rules on the control data type. The buttons display text or add an image, the drop-down box displays strings or objects with an object type attribute as the reference for saving objects. While WPF is different. Its default data type is object, which allows the control to operate on any type of data. This is also one of its flexibility and strength.
Data Type

* Raw Data: String, Boolean, and integer
* List data: array, list, etc. The content in the set can be of the same type or different types of data.
* Hierarchical data: Tree, list, or graph data with hierarchical relationships
* Combined data: data that includes multiple types of data, such as user contact information, including phone number, address 1, address 2, and mobile phone number.

But if it is an object type, how does WPF know how to display the data? This requires templates, presenters, binding and converters, layout, and styles.
Templates)

1. Control template: the control template defines the appearance of a control, which is mainly related to the UI and generally not related to data. Each control has a default control template.

Data Template: a data template is used to customize any template. net Object Appearance, which is very important for non-uielement controls. The default template of non-uielement controls is only a textblock, which contains a string reversed by the tostring method.
You can use the showmethetemplate tool to view the default templates of existing controls.

Content Control (presenters)

Through templates, we now know that the control template defines the control appearance, and the data template defines how to display specific data. How can we display the defined data on the control appearance? The content presenter is required. Each control has a default contentpresenter used to display content. We call this control a content control. contentpresenter is responsible for displaying the content attribute of contentcontrol, as shown in the following code example:
Binding and conversion)

The data template describes the appearance of the data display. How can we associate the appearance with the data? This is what data binding does. WPF data binding is a powerful function that allows single and two-way binding. when an object is changed, the UI is automatically refreshed and the data can be changed automatically after the UI operation.
Sometimes the data format is not just a simple display. For example, if the bool type needs to be displayed in three states, it can be implemented through a single converter.

Binding and converters sample code: For more information, see WPF data binding and binding converters.
Layout)

After the previous steps, the template has been defined, the data is also available, the converter and binding are also triggered, and the content display is generated. The last step is layout ). The layout system determines the size and position of all the preceding UI controls. In WPF, the Panel and its inheritance class are responsible for providing the layout function. The layout is a recursive process in two steps. The first step is called the measurement, and the second step is called the arrange ).

1. Check: The Panel asks how much space its sub-elements need. Here we assume there are enough controls. The Panel will reload the measureoverride method of frameworkelement to implement this step.
2. Arrangement: after the detection step is complete, it is time to arrange the elements. The Panel will tell the child elements where they will be placed and how much space they can use. The Panel will reload the arrangeoverride method of framworkelement to implement this step.

Style)

Style is a simple mechanism by which attribute values and user interface elements can be classified, which is similar to the relationship between CSS and HTML.

The above content can be expressed as: the person data is displayed through the control template, data template, style and layout, and data binding.
Behavior (behavior)

Only half of the work is done to display the data, and half of the work is to provide the user mode to interact with the UI. Describes the input operations:
The WPF control allows you to interact with the UI by using input devices such as the mouse, keyboard, and tablet. You can also perform operations by using external and internal time, after triggering, action can be performed through event processing or command mechanism.

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.