• 个人WPF快速入门笔记 基础样式篇02


    生命 Window.Resources  样式定义

    子节点Style 

       属性 TargetType 指定应用该样式的控件类型(如:Button)

       属性:x:Key 定义样式的名字

       属性:BaseOn 可以集成其他的style样式

         字节点 Setter

            属性 Property 值指定样式属性

            属性Value 值 指定样式属性值

    具体控件使用方式: 

    Style="{StaticResource 样式style名}"

    小节示例Demo:

    <Window x:Class="WpfApp1.example1"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            xmlns:local="clr-namespace:WpfApp1"
            mc:Ignorable="d"
            Title="example1" Height="450" Width="800">
    
        <Window.Resources>
            <Style x:Key="btn1" TargetType="Button">
                <Setter Property="FontSize" Value="25"/>
                <Setter Property="Background" Value="Pink"/>
            </Style>
        </Window.Resources>
    
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition  Height="80px" />
                <RowDefinition Height="100px"/>
                <RowDefinition/>
            </Grid.RowDefinitions>
    
    
    
            <Border Background="#66ccff"  />
            <TextBlock FontSize="25px" TextAlignment="Center" VerticalAlignment="Center"  Text="洛天依天钿智能数据平台" Foreground="#fff" />
    
    
            <Grid Grid.Row="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
    
                <Button Margin="5" Grid.Row="0" Grid.Column="0" Style="{StaticResource btn1}"  TextBlock.Foreground="#fff">手动导入</Button>
                <Button Margin="5" Grid.Row="0" Grid.Column="1" Style="{StaticResource btn1}"  TextBlock.Foreground="Green">开启线程</Button>
                <Button Margin="5" Grid.Row="0" Grid.Column="2" Style="{StaticResource btn1}"  TextBlock.Foreground="red">关闭所有</Button>
                <Button Margin="5" Grid.Row="0" Grid.Column="3"  Style="{StaticResource btn1}" TextBlock.Foreground="#fff">同步站点</Button>
                <Button Margin="5" Grid.Row="0" Grid.Column="4"  Style="{StaticResource btn1}" TextBlock.Foreground="#fff">数据通知</Button>
                <Button Margin="5" Grid.Row="0" Grid.Column="5"  Style="{StaticResource btn1}" TextBlock.Foreground="#fff">日志查询</Button>
            </Grid>
    
    
    
    
        </Grid>
    </Window>
  • 相关阅读:
    Unity3D Resources TextAsset 正文
    使用位操作
    Chapter 3 Protecting the Data(3):创建和使用数据库角色
    找呀志_ContentResolver操作ContentProvider数据
    c#委托实例化和调用语句
    有意练习--Rails RESTful(一)
    对于晚辈:阅读经典“乱搭”形成了自己的“制”
    Eclipse SDK构建J2EE开发环境
    7.oracle学习门户系列七---网络管理和配置
    netback于kthread遇到cpu affinity问题
  • 原文地址:https://www.cnblogs.com/ncellit/p/15941895.html
Copyright © 2020-2023  润新知