WPF Learning Series 5 (WPF control)

Source: Internet
Author: User

Controls:
1. content controls ------ these controls can contain nested elements and provide them with almost unlimited display capabilities. Content controls include lable, button, and tooltip.

Content controls are more special controls that can contain (and display) a piece of content. Technically, a content control can contain a single nested element. Unlike the layout container, the content control can only contain one child element, and the layout control can contain any number of nested elements as long as it is willing.
Tip: Of course, a large amount of content can still be placed in a single content control-the trick is to use a single container, for example, to wrap all content using stackpanel or grid panel. For example, the window class itself is a content control. Obviously, the window contains a large amount of content, but all the content is packaged into a top-level container (this container is usually a grid ).

As learned in Chapter 3, all WPF layout containers inherit the abstract panel class, which provides support for multiple elements. Similarly, all content controls inherit the abstract contentcontrol class.

Content Attributes
Unlike the Panel class that provides a children set to store nested elements, the control class adds a content attribute, which only accepts a single object. The content attribute supports any type of objects, but the objects contained in this attribute can be divided into two categories for different processing:: the object content control that does not inherit from the uielenment class calls the tostring () method of these controls to obtain the text and then displays the text.
B. inherit from objects of the uielenment class. These objects (including all visualization elements, which are components of WPF) are displayed inside the content control using the uielenment. onrender () method.
Note: You can place text content in the content control. The XAML parser converts the content into a string object and uses this string object to set the content attribute. However, instead of rotating the content of a string directly in a layout container, you must use a class inherited from uielement to wrap the string.

The button class indicates the Windows push button that has been used all the time. It adds two writable attributes: iscancel and isdefault.
If the iscancel attribute is set to true, the button becomes the window cancel button. If you press the Escape key at any position in the current window, this button is triggered.
If the isdefault attribute is set to true, the button becomes the default button. Its behavior depends on the current position of the focus in the window. If the focus is on a non-control, if you press enter, the default button is triggered, but if the focus is on another button, the button with the focus currently has a blue shadow, the enter key triggers the current button instead of the default button.
The checkbox control and radiobutton control are different types of buttons. They inherit from the togglebutton class, which means that users can switch their ON and OFF statuses, that is, their switching behavior. For the checkbox control, switching to the open state of the control means placing a check mark in it. No member is added to the checkbox class. Therefore, the basic interface of the checkbox class is defined in the togglebutton class. The most important thing is that the togglebutton class adds the ischecked attribute. It is an empty boolean type. This means that this attribute can be set to true, false, or null. Obviously: true = check box selected, but false is not selected, the null value is a bit troublesome ---------- it indicates that the check box is not in an uncertain state.

The radiobutton control also inherits the togglebutton class and uses the same ischecked attribute and the same checked. It also adds a groupname attribute to control how to Group Single-choice buttons. Radio buttons are usually grouped by their containers, which means that if three radio buttons are placed in a stackpanel, the three radio buttons form a group, you can only select one of the three radio buttons. On the other hand, if you place a single-choice button combination in the two independent stackpanel controls, then there are two separate single-choice buttons. You can use the groupname attribute to override this default behavior. You can use this attribute to create multiple groups in a container or create a group of single-choice buttons in multiple containers.
2. content controls with titles -------------- these controls allow you to add a primary content section and a separate title section. They are usually used to wrap larger user interface blocks. These controls include the tabitem, groupbox, and expander classes.
3. The file control ------------- has few file controls, which allow users to enter text. The text control supports Textbox, passwordbox, and ricktextbox ).
4. Range-based controls ------------ these controls generally only care about one attribute: value, which can be set using any number in the pre-defined range. Examples include slider and progressbar.
5. The date control ------------- contains two controls that allow users to select a date: the calendar and datepicker controls.

    

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.