Silverlight样式定义
2020-12-13 03:17
标签:style blog class code c java 方法一、定义在控件内部 方法二、定义在控件外部 要想让外部样式应用于所有相同类型的控件,只要去掉资源中的样式名称,则TargetType指定的控件都将应用该样式 方法三、定义全局的样式 Silverlight样式定义,搜素材,soscw.com Silverlight样式定义 标签:style blog class code c java 原文地址:http://www.cnblogs.com/qiernonstop/p/3725180.html1 Canvas Background="Red" Height="100" HorizontalAlignment="Left" Margin="90,80,0,0" Name="canvas1" VerticalAlignment="Top" Width="200" />
1 UserControl.Resources>
2 Style x:Key="StyleName" TargetType="Canvas">
3 Setter Property="Background" Value="Red">Setter>
4 Style>
5 UserControl.Resources>
6 Grid x:Name="LayoutRoot" Background="White">
7 Canvas Style="{StaticResource StyleName}" Height="100" HorizontalAlignment="Left" Margin="90,80,0,0" Name="canvas1" VerticalAlignment="Top" Width="200" />
8 Grid>
1 UserControl.Resources>
2 Style TargetType="Canvas">
3 Setter Property="Background" Value="Red">Setter>
4 Style>
5 UserControl.Resources>
6 Grid x:Name="LayoutRoot" Background="White">
7 Canvas Height="100" HorizontalAlignment="Left" Margin="90,80,0,0" Name="canvas1" VerticalAlignment="Top" Width="200" />
8 Canvas Height="100" HorizontalAlignment="Left" Margin="121,188,0,0" Name="canvas2" VerticalAlignment="Top" Width="200" />
9 Grid>
将样式放到App.xaml文件的资源定义里1 Application.Resources>
2 Style TargetType="Canvas">
3 Setter Property="Background" Value="Red">Setter>
4 Style>
5 Application.Resources>