"Programming WPF" translation 5th Chapter 2. Inline style

Source: Internet
Author: User

Each "stylesheet-styled" WPF element has a style attribute that can be set internally-using the XAML attribute-the syntax of the element (discussed in the first chapter), as in example 5-4.

Example 5-4

<Button  x:Name="cell00" />
  <Button.Style>

    <Style>
      <Setter Property="Button.FontSize" Value="32" />
      <Setter Property="Button.FontWeight" Value="Bold" />
    </Style>
  </Button.Style>
</Button>

Because we want to bundle attribute values in our style, we have a STYLE element with two setter child elements, one that we want to set each property, such as FontSize and FontWeight, with a button prefix that indicates the class that contains the attribute. The attributes that apply to styles are dependency properties, which are described in chapter Nineth.

Because of the extra style syntax, and because inline styles cannot be shared across elements, inline styles actually fall into more input when setting properties. For this reason, inline styles are often used without naming styles.

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.