(X) Hide this
    • Login
    • Join
      • Generate New Image
        By clicking 'Register' you accept the terms of use .
        Login with Facebook

Tip: What is control styling?

(1 votes)
Ivan Dragoev
Ivan Dragoev
Joined Oct 25, 2007
Articles:   7
Comments:   9
More Articles
1 comments   /   posted on Nov 14, 2008
Categories:   Design

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!



  • -_-

    RE: Tip: What is control styling?

    posted by SR on May 30, 2010 19:48
    Thanks for cool tip

Add Comment

Login to comment:
  *      *       
Login with Facebook