(wp8.1)样式资源

在开发wp的时候,难免要设置好多属性。但是有好多属性是重复的,我们可不可统一 设置样式呢,答案是肯定的

代码如下

<Page
    x:Class="Blue.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Blue"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Page.Background>
        <SolidColorBrush Color="#FFFAF8EF"/>
    </Page.Background>

    <Page.Resources>
        <Style TargetType="TextBlock" x:Key="HistoryText">
            <Setter Property="FontSize" Value="18"/>
            <Setter Property="Foreground" Value="Black"/>
            <Setter Property="HorizontalAlignment" Value="Right"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
        </Style>
        <Style TargetType="Button" x:Key="ButtonText">
            <Setter Property="Foreground" Value="Black"/>
        </Style>
    </Page.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="2*"/>
            <RowDefinition Height="5*"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="3*"/>
            <ColumnDefinition Width="2*"/>
        </Grid.ColumnDefinitions>
        <!--游戏标题-->
        <StackPanel>
            <TextBlock Foreground="Black" FontSize="60">蓝色拼图</TextBlock>
            <StackPanel Orientation="Horizontal">
                <Button Margin="10,0" Style="{StaticResource ButtonText}">重新开始</Button>

                <Button Style="{StaticResource ButtonText}">说明</Button>
            </StackPanel>
        </StackPanel>
        
        <!--历史面板-->
        <Grid Grid.Column="1" Margin="10">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Column="0" Grid.Row="0" Style="{StaticResource HistoryText}" ></TextBlock>
            <TextBlock Grid.Column="1" Grid.Row="0" Style="{StaticResource HistoryText}" >当前</TextBlock>
            <TextBlock Grid.Column="2" Grid.Row="0" Style="{StaticResource HistoryText}" >历史</TextBlock>
            <TextBlock Grid.Column="0" Grid.Row="1" Style="{StaticResource HistoryText}" >级别</TextBlock>
            <TextBlock Grid.Column="1" Grid.Row="1" Style="{StaticResource HistoryText}" >6</TextBlock>
            <TextBlock Grid.Column="2" Grid.Row="1" Style="{StaticResource HistoryText}" >6</TextBlock>
            <TextBlock Grid.Column="0" Grid.Row="2" Style="{StaticResource HistoryText}" >点击</TextBlock>
            <TextBlock Grid.Column="1" Grid.Row="2" Style="{StaticResource HistoryText}" >22</TextBlock>
            <TextBlock Grid.Column="2" Grid.Row="2" Style="{StaticResource HistoryText}" >22</TextBlock>
        </Grid>

    </Grid>
    
</Page>

 

你可能感兴趣的:(样式)