zoukankan      html  css  js  c++  java
  • [转]silverlight中定义样式

    作用域:定义所有的样式

    1. <Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    2.              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   
    3.              x:Class="SilverlightApplication1.App"  
    4.              >  
    5.     <Application.Resources>  
    6.         <Style TargetType="Button">  
    7.             <Setter Property="Background" Value="Beige"></Setter>  
    8.             <Setter Property="FontSize" Value="25"></Setter>  
    9.             <Setter Property="Foreground" Value="Blue"></Setter>  
    10.             <Setter Property="Margin" Value="20"></Setter>            
    11.         </Style>  
    12.     </Application.Resources>  
    13. </Application>  


    一般的样式引用

     

      1. <UserControl x:Class="SilverlightApplication1.SilverlightControl1"  
      2.     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
      3.     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
      4.     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"  
      5.     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  
      6.     mc:Ignorable="d"  
      7.     d:DesignHeight="300" d:DesignWidth="400">  
      8.     <UserControl.Resources>  
      9.         <Style x:Key="button1" TargetType="Button">  
      10.             <Setter Property="Background" Value="Beige"></Setter>  
      11.             <Setter Property="FontSize" Value="25"></Setter>  
      12.             <Setter Property="Foreground" Value="Blue"></Setter>  
      13.             <Setter Property="Margin" Value="20"></Setter>  
      14.         </Style>  
      15.         <Style x:Key="button2" TargetType="Button">  
      16.             <Setter Property="Background" Value="Wheat"></Setter>  
      17.             <Setter Property="FontSize" Value="24"></Setter>  
      18.             <Setter Property="Foreground" Value="Red"></Setter>  
      19.             <Setter Property="Margin" Value="20"></Setter>  
      20.         </Style>  
      21.     </UserControl.Resources>  
      22.   
      23.     <StackPanel x:Name="LayoutRoot1" Width="800" Height="180"   
      24.                     Orientation="Horizontal"  
      25.                     Background="White"  
      26.                     HorizontalAlignment="Center">  
      27.         <Button Content="样式1" Width="200" Height="70" Style="{StaticResource button1}"/>  
      28.         <Button Content="样式1" Width="200" Height="70" Style="{StaticResource button2}"/>  
      29.         <Button Content="样式3"   Width="200" Height="80" >  
      30.             <Button.Style>  
      31.                 <Style TargetType="Button">  
      32.                     <Setter Property="Background" Value="Red"></Setter>  
      33.                     <Setter Property="FontSize" Value="20"></Setter>  
      34.                     <Setter Property="Foreground" Value="Beige"></Setter>  
      35.                     <Setter Property="Margin" Value="20"></Setter>  
      36.                 </Style>  
      37.             </Button.Style>  
      38.         </Button>  
      39.         <Button  Content="App"></Button>  
      40.   
      41.     </StackPanel>  
      42.   
      43. </UserControl>  
  • 相关阅读:
    电信的星空极速客户端软件强制安装策略升级了
    CSS 控件适配器工具包对事件处理的 Bug 以及修正办法
    IronPython 源码剖析系列(1):IronPython 编译器
    对 CSS 控件适配器处理事件的 Bug 进一步修正
    明天去长春出差。。。
    Windows 系统右键菜单假死问题解决一例
    使用 Anthem.NET 的常见回调(Callback)处理方式小结
    TreeViewVisitor: 一个快捷访问 TreeView 控件节点的帮助类
    ASP.NET Web开发框架之六 数据库文档方法,工具和实践
    推荐功能强大的ORM Profiler,ORM问题追踪的利器
  • 原文地址:https://www.cnblogs.com/wangshenhe/p/2975127.html
Copyright © 2011-2022 走看看