Recommended

Skip Navigation LinksHome / Search

Search

 
Results Per Page

Found 1 result for Silverlight Styling.
Date between: <not defined> and <not defined>
Search in: News , Articles , Tips , Shows , Showcase , Books

Order by Publish Date   Ascending Title   Rating  

  • 1 comments  /  posted by  Ivan Dragoev  on  Nov 13, 2008 (more than a year ago)

    Styling control is a very easy way to tweak the minor visual characteristic of the control such as foreground and background colors, the font style and size, padding, etc. Usually the styles are stored as resources which allows you to reuse them whenever you want.

    The Style has TargetType specifying the type of the object the style can be applied to and a key used to identify the style. The Style contains numerous Setters, which describe the values which you want to set to specific properties.

    To apply style to a control simply specify the Style property of the control to point to the static resource with a specific key name.

       1: <Grid>
       2:     <Grid.Resources>
       3:         <Style TargetType="Button" x:Key="myButtonStyle">
       4:             <Setter Property="Width" Value="100" />
       5:             <Setter Property="Height" Value="25" />
       6:             <Setter Property="Foreground" Value="#FF87091F"/>
       7:             <Setter Property="Padding" Value="2"/>
       8:             <Setter Property="BorderThickness" Value="4"/>
       9:             <Setter Property="FontWeight" Value="Bold" />
      10:             <Setter Property="FontFamily" Value="Portable User Interface" />
      11:         </Style>
      12:     </Grid.Resources>
      13:     <Button Content="Click Me!" Style="{StaticResource myButtonStyle}">
      14:     </Button>        
      15: </Grid>

     That's it!




Help us make SilverlightShow even better and win a free t-shirt. Whether you'd like to suggest a change in the structure, content organization, section layout or any other aspect of SilverlightShow appearance - we'd love to hear from you! Need a material (article, tutorial, or other) on a specific topic? Let us know and SilverlightShow content authors will work to have that prepared for you. (hide this)