Learning Silverlight 2 Series (8): Using styles to encapsulate control impressions

Source: Internet
Author: User
Tags silverlight

This is the eighth article in the series, which describes the use of style elements in Silverlight to encapsulate control impressions

Silverlight supports a Style mechanism that allows us to encapsulate the property values of a control into reusable resources. We can store these style declarations in separate files from the page, and then reuse them across controls and pages in one application (or even reuse across multiple applications). In a basic customization scenario, it's conceptually similar to reusing CSS in HTML.

inline style

Inline style This concept is actually the same as the style of the elements we specify in the HTML, set by attributes in XAML, as in the following XAML, we added two buttons and set the font style in it:

<Canvas Background="#46461F">
  <Button Width="200" Height="60" Background="Red"
       Canvas.Top="90" Canvas.Left="30" Content="提 交"
       FontFamily="微软雅黑"
      FontSize="24"
       FontWeight="Bold"
      Foreground="Green"/>
  
   <Button Width="200" Height="60" Background="Red"
       Canvas.Top="90" Canvas.Left="260" Content="取 消"
       FontFamily="微软雅黑"
      FontSize="24"
       FontWeight="Bold"
       Foreground="Red"/>
</Canvas>

The results of the run display are as follows:

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.