Chapter4: using standard control (learning)

Source: Internet
Author: User
Contentcontrol

<Button>, <scrollviewer>, <label>, <checkbox>, <radiobutton>, <tooltip>

1: contentcontrol class has a type of object content attribute, which can be anything. Eg: The content of the button control can be any form of element :( text, text + image, image) and a contenttemplate attribute can receive controls of the ememplate type.

2: The content attribute of contentcontrol can be implicitly expressed.

View code

 <  Button  Margin  = "4"  Horizontalalignment  = "Left"  Padding  = "4" >              <  Stackpanel  Orientation  = "Horizontal"  >                  <  Image  Source  = "Copy.png"  Width  = "16"  Height  = "16"  />                  <  Textblock Text  = "Copy"  Margin  ="  Verticalalignment  = "Center"  Fontsize  = "16"  />                                     </  Stackpanel  >          </  Button  > 

It can also be explicitly expressed

View code

 
<ButtonContent="{Staticresource P1}"Fontsize= "16"Margin= "4"Padding= "4"Horizontalalignment= "Left"/>

3: content attribute setting rules for contentcontrol

  • If the content attribute is string, textblock will be render. The text attribute of textblock is this string
  • If the content attribute is implicitly expressed ( content is directly inserted in ... ) is a uielement object , the uielement is render. If it is a row of uielement ( ). If there are multiple rows ( + ) add a panel ( , , )
  • If the contenttemplate attribute is null,ContentProperty is customObjectThenRenderedTextblockWith itsText attributesSet toTostring MethodOfContent attribute value (ObjectType), OtherwiseDatatempateApplied
  • Note:All types of attributes may not be set only in XAML, but can also be set in background. CS, where to use them flexibly. HoweverContentcontrolOfContentAttribute, you must firstContentcontrolDefine an X: Name = "? ", Then the background can be

    View code

 

Headered contentcontrol:<Groupbox>

1: inherited from contentcontrol. Besides the existing content and contenttemplate attributes, there are two more attributes (HeaderTypeObject,HeadertemplateTypeDatatemplate). All four attributes comply with the preceding Property setting rules.

?. Content = ?. Header =NewBook {name="Windows Internals", Author="Mark russinovich", Yearpublished=2009};}
Itemscontrol

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.