Innovations in the WPF UI

Source: Internet
Author: User

According to Microsoft's best practices for Windows Vista and WPF, I believe many developers only have two words to describe the UI capabilities of WPF, for how to use WPF to improve these effects, based on the fact that many articles have been discussed on the website, the author will not repeat them here, directly put the master role at the core of WPF, that is, how she builds an environment for these effects. The large UI interface of WPF is based on two related technologies. One is the operating system of the graphic control. In the windows program of the traditional system, most of them use controls built in Windows to create the UI interface. These controls include ComboBox, Textbox, RichTextBox, And button, directly using these controls not only gives users a consistent operation interface, but also allows them to be created in windows, so they also have a certain degree of performance, however, in this case, the controls are also subject to external restrictions. The effect of Displaying Multiple metadata in ComboBox and rotating the textbox to 45 degrees is always simplified, of course! Many programmers who are familiar with Windows propose that to achieve these effects, they only need to create window objects without using the internal controls, and then compile the necessary external parameters, yes! This is indeed one of the ways to achieve these effects in the past generation,! In fact, this is too complicated, because in addition to the foreign currency, programmers have to handle a large amount of interest, just to say! When you want to create a rotatable Textbox, the programmer must handle the cursor, mouse, and other messages in addition to the reserved textbox. In the WPF era, all these controls will become simple, because almost all the controls in WPF are made by WPF, the spy ++ tool can be used to verify the authentication between Windows Forms and WPF programs (the WPF program and the Windows Forms Program are listed above ). The UI interfaces of these two programs are the same, but we can see from examples that there are also child controls such as button2 and button1 in the Windows Forms (lower) window, however, there is a large handle window in the WPF window above. This is the big handle concept of WPF. It only uses a Windows-provided base partition object: window, all the child controls in this window are output and managed by WPF, So spy ++ can only see one basic Object window. Since WPF outputs the control, it also means that it is possible to spin the textbox in WPF, but in reality! Controls in WPF already provide the spin-off capability, even if programmers have the need to write self-built controls, you only need to inherit from the uielement (the basis of the UI control in WPF) to be able to rotate. So how should we handle the interest part? This requires the second anti-DDoS Technology in WPF: a self-contained messaging system. When a user moves the mouse over a window, window will receive the wm_mousemove parameter from the Windows system, and then window will refer to the X and Y parameters in the parameter, obtain the corresponding uielement object to send the response message. The overall running mode is as follows. In the window mode of WPF, dispatcher sends messages from windows, and then sends messages to windows, that is, the hwndsource object of windows, this object calls an inputprovider object to handle incoming messages. In this example, two inputprovider objects are stored: hwndkeyboardinputprovider, and hwndmouseinputprovider, handle mouse parameters and mouse parameters separately. In hwndmouseinputprovider, after receiving the mouse response, she calculates the mouse position and finds the corresponding uielement, then, the system calls inputmanager to send messages to the uielement. Who initiated the dispatcher? In the window-based WPF program, the answer is the run function of the Application object. She will call the run function of the dispatcher. This function will enter the cycle of the Response Message, until this program is disabled.

 

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.