Introduction to three WPF templates and three wpf templates

Source: Internet
Author: User

Introduction to three WPF templates and three wpf templates

WPF supports the following types of templates:

(1) control template. A control template can apply a custom template to all controls of a specific type or an instance of a control. The ControlTemplate determines the control's appearance. It determines what the control looks like. Therefore, the control template is represented by the ControlTemplate class. The control template is actually defined in the resource set or resource dictionary. For example, see: Design ControlTemplate to create a rounded corner text box and a rounded corner button (http://www.cnblogs.com/zhouhb/p/3284780.html ).

(2) Data Template. In WPF, DataTemplate determines the data appearance, that is, DataTemplate represents the data content. What is a piece of data displayed? Is it a simple text or intuitive image, it is determined by DataTemplate. See DataTemplate application (http://www.cnblogs.com/zhouhb/p/3284827.html) for details ).

(3) ItemsPanelTemplate. ItemsPanelTemplate specifies the Panel used for the layout of items. The following example sets the ItemsPanelTemplate of ListBox to display each item in sequence from left to right.

WrapPanel positions the child element from left to right in sequence and disconnects the content from the edge of the contained box to the next line. The subsequent sorting is performed from top to bottom or from right to left, depending on the value of the Orientation attribute (the default value is Horizontal ).

<ListBox AllowDrop = "True" Margin = "0, 1, 262,0">
<ListBox. ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel/>
</ItemsPanelTemplate>
</ListBox. ItemsPanel>
<Label Name = "label1" Content = "E"/>
<Label Name = "label2" Content = "A"/>
<Label Name = "label3" Content = "I"/>
<Label Name = "label4" Content = "M"/>
</ListBox>

Running effect:

Three templates for WPF learning, you can further reference: WPF detailed templates (http://www.cnblogs.com/dingli/archive/2011/07/20/2112150.html ).

 

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.