zoukankan      html  css  js  c++  java
  • 【Windows Phone 8】样式

    类似于Html样式,有三种设置方法。

    1.内联样式

    直接在控件中设置样式,类似于html中的控件中设置样式。

    1             <Button Content="内联样式">
    2                 <Button.Style>
    3                     <Style TargetType="Button">
    4                         <Setter Property="Background" Value="Red"></Setter>
    5                         <Setter Property="FontSize" Value="20"></Setter>
    6                     </Style>
    7                 </Button.Style>
    8             </Button>
    内联样式

    2.内部样式表

    在xaml页面定义的样式,通过x:key设置样式名称

    1     <phone:PhoneApplicationPage.Resources>
    2         <Style x:Key="CommonButton" TargetType="Button">
    3             <Setter Property="Background" Value="Blue"></Setter>
    4             <Setter Property="FontSize" Value="25"></Setter>
    5         </Style>
    6     </phone:PhoneApplicationPage.Resources>
    内部样式表--定义样式
    1 <Button Content="导航到Page1" Style="{StaticResource CommonButton}" />
    内部样式表--使用样式

    3.外部样式

    类似于html的css样式文件,将样式集中定义在外部的样式文件中。

    关于xaml样式文件的定义可以参考Windows Phone SDK安装后文件中的ThemeResources.xaml文件,在此基础上进行修改。

     1 <ResourceDictionary
     2   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     3   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     4   xmlns:System="clr-namespace:System;assembly=mscorlib">
     5 
     6     <Style x:Name="ButtonOutStyle" TargetType="Button">
     7         <Setter Property="Background" Value="Green"></Setter>
     8         <Setter Property="FontSize" Value="30"></Setter>
     9     </Style>
    10 </ResourceDictionary>
    11 
    12   
    外部样式--定义样式

    同时需要修改App.xaml文件,添加该样式资源

    1 <Application.Resources>       
    2   <ResourceDictionary>           
    3   <ResourceDictionary.MergedDictionaries>               
    4     <ResourceDictionary Source="CustomTheme/ThemeResources.xaml"/>
    5   </ResourceDictionary.MergedDictionaries>       
    6   </ResourceDictionary>   
    7 </Application.Resources> 
    App.xaml
    1 <Button Content="外部样式" Style="{StaticResource ButtonOutStyle}"></Button>
    外部样式--使用样式
  • 相关阅读:
    jvisualm 结合 visualGC 进行jvm监控,并分析垃圾回收
    linux 查看服务器cpu 与内存配置
    arthas 使用总结
    selinux contexts 安全上下文的临时更改
    Android 8.1 Doze模式分析(五) Doze白名单及Debug方式
    Window 任意窗口置顶软件Window TopMost Control
    Android ApkToolPlus一个可视化的跨平台 apk 分析工具
    SVN Please execute the 'Cleanup' command.
    Android 如何在64位安卓系统中使用32位SO库
    Android cmd命令查看apk是32位还是64位?
  • 原文地址:https://www.cnblogs.com/fb-boy/p/3544484.html
Copyright © 2011-2022 走看看