• 【WPF】二、样式基础


    <Window x:Class="WpfApp1.MainWindow"
            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="MainWindow" Height="450" Width="800">
        <Window.Resources>
            <!--这是基础的模板其他控件可以引用-->
            <Style x:Key="BaseText" TargetType="TextBox" >
                <Setter Property="FontSize" Value="18"></Setter>
                <Setter Property="Foreground" Value="White"></Setter>
                <Setter Property="Background" Value="LightBlue"></Setter>
            </Style>
            <!--这是引用后的控件-->
            <Style x:Key="inputText"  TargetType="TextBox"  BasedOn="{StaticResource BaseText}">
                <Setter Property="Text" Value="请输入身份证号"></Setter>
            </Style>
            <!--这是一个button控件样式-->
            <Style x:Key="clickButton" TargetType="Button">
                <Setter Property="FontSize" Value="18"></Setter>
                <Setter Property="Content" Value="查询"></Setter>
                <Setter Property="Foreground" Value="White"></Setter>
                <Setter Property="Background" Value="Orange"></Setter>
            </Style>
    
        </Window.Resources>
        <Grid>
            <StackPanel>
                <Label>33</Label>
                <!--控件样式实现方式-->
                <TextBox Style="{StaticResource inputText}"></TextBox>
                <Button Style="{StaticResource clickButton}"></Button>
            </StackPanel>
            
        </Grid>
    </Window>
  • 相关阅读:
    pyinstall打包工具
    python中用xlsxwriter创建图表
    python打包工具 cx_Freeze介绍
    JavaScript、Dom和jQuery
    MHA原理
    mysql-mmm实现高可用和部署时须要考虑的问题
    jquery中attr和prop的区别
    FLUSH TABLES WITH READ LOCK 获取锁的速度
    Python Memcached、Redis & RabbitMQ使用
    innodb_flush_log_at_trx_commit
  • 原文地址:https://www.cnblogs.com/xxxyz/p/16629411.html
Copyright © 2020-2023  润新知