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>
  • 相关阅读:
    vue.config.js的配置与注释
    Git Pages,使用gh-pages分支显示静态网站
    git subtree 公共仓库
    vue之计算属性
    前端模块化AMD和CMD
    jQuery实现表单全选反选,简洁,好用
    vue之点击切换样式
    vue之本地代理解决跨域问题
    ES6
    jQuery 总结
  • 原文地址:https://www.cnblogs.com/langhua/p/2052984.html
Copyright © 2011-2022 走看看