Silverlight页面级样式的使用
<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">
/**********在这里定义了样式,其中的x:key 是唯一值,可用于识别,就好比是css中的id********/
<UserControl.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>
</UserControl.Resources>
<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>
浙公网安备 33010602011771号