zoukankan      html  css  js  c++  java
  • windo phone8.1 样式的基本使用(一)

                          样式的基本使用(一)

    当一个项目中有多个控件出现相同的属性设置,那么可以使用以下解决办法

     

    方法一:

    <Page.Resources>

        <!--向资源字典中添加一个键为Buttonground,值为SolidColorBrush对象-->

        <SolidColorBrush 

                x:Key="ButtonBackground"

                Color="Aqua"/>

        <SolidColorBrush

                x:Key="ButtonForeground"

                Color="Red"/>

        <x:Double x:Key="ButtonFontSize">30</x:Double>

    </Page.Resources>

    <Grid>

        <Button

                Content="Button"

                Background="{StaticResource ButtonBackground}"

                Foreground="{StaticResource ButtonForeground}"

                FontSize="{StaticResource ButtonFontSize}"/>

    </Grid>

     

    方法二:

    <Page.Resources>

        <Page.Resources>

            <!--类型选择器-->

            <!--键是唯一的,不能重复定义-->

            <!--style节点可以不用指定一个具体的键,有一个默认的键(typeof(Button))-->

            <Style TargetType="Button">

                <Setter Property="Width" Value="200"/>

            </Style>

            <!--解决类型选择器重名的问题-->

            <Style x:Key="ButtontowStyle" TargetType="Button">

                <Setter Property="Width" Value="300"/>

                <Setter Property="Background">

                    <Setter.Value>

                        <SolidColorBrush Color="Aqua"/>

                    </Setter.Value>

                </Setter>

            </Style>

        </Page.Resources>

        <StackPanel>

            <Button

                Content="Button1"/>

            <!--Button的Style默认指向的键为this.GetType()-->

            <Button

                Content="Button2"

                Style="{StaticResource ButtontowStyle}"/>

    </StackPanel>

     

     

     

     

  • 相关阅读:
    通过输入方式在Android上进行微博OAuth登录
    Android应用集成支付宝接口的简化
    Tomcat启动时报 java.lang.OutOfMemoryError: Java heap space
    Myeclipse中 Exploded location overlaps an existing deployment解决办法
    SVN提交项目时版本冲突解决方案
    Jsp过滤器Filter配置过滤类型汇总
    myeclipse修改jsp文件的名称之后,再也打不开的解决方案
    文件上传之 commons-fileupload(二)
    文件上传之 commons-fileupload(一)
    常见池化技术
  • 原文地址:https://www.cnblogs.com/fenger-VIP/p/4268937.html
Copyright © 2011-2022 走看看