"Programming WPF" translation 3rd Chapter 1. What is a control

Source: Internet
Author: User

For an application, the control is the building block that builds the user interface. They have interactive features such as text boxes, buttons, and list boxes. Nevertheless, WPF is a bit unusual in that it does not directly depend on its appearance. When customizing a control's appearance, many GUI frameworks require designers to write a custom control. In WPF, this is not necessary: embedded content and templates provide a simple and powerful solution. Only if you need a control whose behavior does not exist in an existing nested control, you need to develop it again.

Many WPF user interface elements are not controls. For example, some shapes: Rectangle, Ellipse, they do not have intrinsic behavior, just a look.

Figure 3-1 shows how to fit a control to a program. As you can see, the visible part of the control is provided by its template, not by the control itself. This control is not completely detached from its appearance, and of course, the control uses these skins to provide information to the user. In addition, because these skins are all that the user can see, they will be immediate targets entered by any user. This means that while these skins can be replaced, these replacements have specific responsibilities. There is a contractual way between the control and its appearance. Templates, which are used to replace the appearance of the control, are discussed in chapter 5th.

Figure 3-1

You may be familiar with the MVC (Model View Controller) concept. This is a way to design an interactive system. In the past, MVC has already had several ways of interpreting it. But broadly speaking, it often splits the design into: objects that represent the underlying data (Model), objects that display data (View), manage user input, and manage objects that interact with the View (Controller).

Although the control makes itself visible to the user by its appearance, the API (see Figure 3-1 left) makes its services available to the developer. Control provides the concept of a command to provide its supported operations. For example, a text box provides the cut, copy, and Paste commands. Control provides the concept of a property, providing a way to modify the behavior or appearance. When something important happens, such as receiving input from outside, the control activates the event. Finally, some functions are exposed through method. Priority is given to selecting commands, properties, and events because they are easy to use in markup languages and are supported by some design tools. Still, there are situations where these controls are used in the background code, which is the most appropriate API representation.

Of course, developers and designers are not the only ones who use controls. Control to respond to the user at the same time, so let's take a look at how the input is handled in WPF.

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.