Wednesday, March 20, 2013

How do I create styles like those in a CSS file?

There's a Style element you can use to hold styles. They have to target a control type to work.

Simple Comparison 

HTML:

.MyButtonStyle {
    width: 250px;
    background-color: black;
    color: goldenrod;
}
In use:
<asp:Button Text="Hello" runat="server" CssClass="MyButtonStyle" /> 

XAML:

<Style x:Name="MyButtonStyle" TargetType="Button">
    <Setter Property="Width" Value="250" />
    <Setter Property="Background" Value="Black" />
    <Setter Property="Foreground" Value="Goldenrod" />
</Style>
In use:
<Button Content="Hello" Style="{StaticResource MyButtonStyle}" />

No comments:

Post a Comment