Silverlight全局样式的使用

    将样式写在app.xaml文件里
<Application.Resources>
        <Style TargetType="Button" x:Key="ButtonStyle">
            <Setter Property="FontSize" Value="18"/>
            <Setter Property="FontFamily" Value="黑体"/>
        </Style>
        <Style TargetType="TextBox" x:Key="TextboxStyle">
            <Setter Property="FontSize" Value="18"/>
            <Setter Property="FontFamily" Value="黑体"/>
        </Style>
    </Application.Resources>
</Application>

在page.xaml里调用样式,调用方法与页级样式一样!
    <UserControl
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 x:Class="SilverlightApplication2.Page"
 Width="640" Height="480">
        <Grid x:Name="LayoutRoot" Background="White">
        <Button Height="58" Margin="236,0,277,123" VerticalAlignment="Bottom" Content="按钮" x:Name="btn" Click="btn_Click" Style="{StaticResource ButtonStyle}"/>
        <TextBox Height="82" Margin="145,132,158,0" VerticalAlignment="Top" Text="内容" TextWrapping="Wrap" x:Name="txt" Style="{StaticResource TextboxStyle}"/>
    </Grid>
</UserControl>
posted on 2009-07-23 11:31  晴天1848  阅读(526)  评论(0)    收藏  举报