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>

     

     

     

     

  • 相关阅读:
    vue语法 `${ }` (模版字符串)
    Apache HttpClient工具类
    JS —— 数组去重
    HTML5——新增的API
    HTML5——新特性
    HTML5——Svg
    HTML5——多媒体(Audio音频、Video视频)
    CSS3——transform
    CSS3——animation中的属性--steps
    CSS3——动画transition、animation
  • 原文地址:https://www.cnblogs.com/fenger-VIP/p/4268937.html
Copyright © 2011-2022 走看看