zoukankan      html  css  js  c++  java
  • Silveright全局样式应用

    在Web开发中要保持风格样式的一致性,在asp.net中做法是提取样式,写在一个CSS文件中,在web页面中添加对这个样式的引用,

    在此要说的是Silverlight中做法,稍有些不同,

    第一步,建立样式文件,并添加到Assets文件夹中,如图所示

    建立样式文件

    第二步,在App.xaml文件中指定样式文件路径

     1     <Application.Resources>
     2         <ResourceDictionary>
     3             <ResourceDictionary.MergedDictionaries>
     4                 <ResourceDictionary Source="Assets/Styles.xaml"/>
     5                 <ResourceDictionary Source="Assets/Brushes.xaml"/>
     6                 <ResourceDictionary Source="Assets/CoreStyles.xaml"/>
     7                 <ResourceDictionary Source="Assets/SDKStyles.xaml"/>
     8                 <ResourceDictionary Source="Assets/ToolkitStyles.xaml"/>
     9             </ResourceDictionary.MergedDictionaries>
    10         </ResourceDictionary>
    11     </Application.Resources>

    第三步,就可以在页面文件中引用所添加的样式啦,

        <Border x:Name="contentBorder" Style="{StaticResource ContentBorderStyle}">
            
    <TextBlock Text="真心真意过一生"/>
        
    </Border>

    补充:

    样式文件写法,以TextBlock控件为例:

    先写要控件的属性然后是属性值,类似字典的方式,

    1     <Style x:Key="TextBlockStyle" TargetType="TextBlock">
    2         <Setter Property="Foreground" Value="{StaticResource BodyTextColorBrush}"/>
    3         <Setter Property="FontFamily" Value="{StaticResource HeaderFontFamily}"/>
    4         <Setter Property="FontSize" Value="{StaticResource ContentFontSize}"/>
    5         <Setter Property="TextWrapping" Value="Wrap"/>
    6         <Setter Property="Margin" Value="0,2,0,2"/>
    7         <Setter Property="HorizontalAlignment" Value="Left"/>
    8         <Setter Property="TextOptions.TextHintingMode" Value="Animated" />
    9     </Style>
  • 相关阅读:
    【转】Redis主从复制简介
    Redis配置文件详解
    Redis在Windows环境下搭建
    Redis桌面管理工具 RedisDesktopManager
    Redis服务停止报错解决方案[NOAUTH Authentication required]
    Redis启动警告错误解决
    修改tcp内核参数:somaxconn
    CentOS6.8安装Redis3.2.5
    Github之协同开发
    自定义实现栈的功能
  • 原文地址:https://www.cnblogs.com/langhua/p/2052984.html
Copyright © 2011-2022 走看看