zoukankan      html  css  js  c++  java
  • WPF 四种样式

    1、内联样式
    <TextBlock FontSize="20" Foreground="Blue">好啊</TextBlock>


    2、页面样式
    <Button Height="20" Margin="0,78,445,213>按钮1</Button>
    <Button Width="50" Height="20" Margin="0,116,453,175">按钮2</Button>

    <Window.Resources>
    <Style TargetType="Button" x:Key="MyStyle">
    <Setter Property="Foreground" Value="Blue"></Setter>
    <Setter Property="FontSize" Value="30"></Setter>
    </Style>
    </Window.Resources>

    应用特性名称样式:
    在样式中添加x:key属性
    <Style TargetType="Button" x:Key="MyStyle">
    <Setter Property="Foreground" Value="BlanchedAlmond"></Setter>
    <Setter Property="FontSize" Value="30"></Setter>
    </Style>

    然后应用该样式 <Button Height="20" Margin="0,78,445,213" Style="{StaticResource MyStyle}">按钮1</Button>

    3、全局样式
    在App.xaml中添加
    <Application.Resources>
    <Style TargetType="Button" x:Key="MyStyle">
    <Setter Property="Foreground" Value="Blue"></Setter>
    <Setter Property="FontSize" Value="30"></Setter>
    </Style>
    </Application.Resources>

    4、外部样式
    新建Dictionary1.xaml文件
    <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style TargetType="Button" x:Key="MyStyle">
    <Setter Property="Foreground" Value="Blue"></Setter>
    <Setter Property="FontSize" Value="30"></Setter>
    </Style>
    </ResourceDictionary>

    在引用页面添加
    <Window.Resources>
    <ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="Dictionary1.xaml"></ResourceDictionary>
    </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
    </Window.Resources>

  • 相关阅读:
    ChinaCock界面控件介绍-CCLoadingIndicator
    delphi-search-path-vs-library-path-vs-browsing-path
    10.3制作Android Splash启动界面
    FMX取得屏分辨率
    REST easy with kbmMW #20 – OpenAPI and Swagger UI
    升级ChinaCock 10.3遇到的问题
    FastJson中的ObjectMapper对象的使用详解
    fastjson的值过滤器ValueFilter
    springboot 2.0 配置 spring.jackson.date-format 不生效
    War 包部署
  • 原文地址:https://www.cnblogs.com/Benjamin/p/3870620.html
Copyright © 2011-2022 走看看