win8第六步样式

内部样式

win8第六步样式
<Page
    x:Class="App2.StylePage1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App2"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Page.Resources>
        <Style TargetType="Button"> 如果不是设置x:key则页面内所有button均使用这个样式
            <Setter Property="Background">
                <Setter.Value>
                    <LinearGradientBrush>
                        <GradientStop Color="Red" Offset="0"></GradientStop>
                        <GradientStop Color="Blue" Offset="1"></GradientStop>
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="BorderBrush" Value="Blue"></Setter>
        </Style>
        <Style TargetType="Button" x:Key="btnStyle1">  只有Stype="{StaticResource btnStyle1}"才使用
            <Setter Property="Background">
                <Setter.Value>
                    <LinearGradientBrush>
                        <GradientStop Color="Yellow" Offset="0"></GradientStop>
                        <GradientStop Color="Green" Offset="1"></GradientStop>
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="BorderBrush" Value="Blue"></Setter>
        </Style>
    </Page.Resources>
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Button Content="Button" HorizontalAlignment="Left" Margin="286,99,0,0" VerticalAlignment="Top"/>
        <Button Content="Button" HorizontalAlignment="Left" Margin="391,99,0,0" VerticalAlignment="Top"/>
        <Button Content="Button" HorizontalAlignment="Left" Margin="490,99,0,0" VerticalAlignment="Top"/>
        <Button Content="Button" Style="{StaticResource btnStyle1}" HorizontalAlignment="Left" Margin="286,224,0,0" VerticalAlignment="Top"/>
        <Button Content="Button" HorizontalAlignment="Left" Margin="391,224,0,0" VerticalAlignment="Top"/>

    </Grid>
</Page>
win8第六步样式

外部样式

win8第六步样式
<Page
    x:Class="App2.BlankPage1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App2"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Page.Resources>
        <ResourceDictionary Source="SkinHot.xaml"></ResourceDictionary>    引入外部样式文件
    </Page.Resources>
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">    normalBtn为外部样式key
        <Button Style="{StaticResource normalBtn}" Content="Button" HorizontalAlignment="Left" Margin="534,149,0,0" VerticalAlignment="Top"/>
    </Grid>
</Page>
win8第六步样式

外部样式文件

win8第六步样式
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App2">
    <Style TargetType="Button" x:Key="normalBtn">
        <Setter Property="Background">
            <Setter.Value>
                <SolidColorBrush Color="Pink"></SolidColorBrush>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
win8第六步样式

win8第六步样式,布布扣,bubuko.com

win8第六步样式

上一篇:LoadRunner 添加linux,windows监控资源


下一篇:Windows 8.1 自带输入法无法调用