首页 > Windows开发 > 详细

wpf 的style

时间:2021-06-05 11:27:35      阅读:14      评论:0      收藏:0      [点我收藏+]

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

 

    <Style x:Key="ImageButtonStyle" TargetType="Button">

        <Setter Property="BorderBrush" Value="Transparent"/>

        <Setter Property="BorderThickness" Value="0"/>

        <Setter Property="FontFamily" Value="{StaticResource GothamMedium}"/>

        <Setter Property="Foreground" Value="#818181"/>

        <Setter Property="Background" Value="Transparent"/>

        <Setter Property="Template">

            <Setter.Value>

                <ControlTemplate TargetType="Button">

                    <Border x:Name="border"

                        Background="{TemplateBinding Background}"

    Padding="{TemplateBinding Padding}"

    BorderBrush="{TemplateBinding BorderBrush}"

    BorderThickness="{TemplateBinding BorderThickness}"

    SnapsToDevicePixels="True"

                        CornerRadius="3">

                        <ContentPresenter Content="{TemplateBinding Content}" VerticalAlignment="Center" HorizontalAlignment="Center"

        Focusable="False" RecognizesAccessKey="True"/>

                    </Border>

                    <ControlTemplate.Triggers>

                        <Trigger Property="IsMouseOver" Value="True">

                            <Setter TargetName="border" Property="Background" Value="#3F3F3F"/>

                        </Trigger>

                    </ControlTemplate.Triggers>

                </ControlTemplate>

            </Setter.Value>

        </Setter>

    </Style>

 

</ResourceDictionary>

 

wpf style

---------------------------------------------------------

 

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

 

                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

 

 

 

    <Style x:Key="ToggleButtonStyle" TargetType="ToggleButton">

 

        <Setter Property="Foreground" Value="#818181"/>

 

        <Setter Property="Background" Value="Transparent"/>

 

        <Setter Property="HorizontalContentAlignment" Value="Center"/>

 

        <Setter Property="VerticalContentAlignment" Value="Center"/>

 

        <Setter Property="HorizontalAlignment" Value="Center"/>

 

        <Setter Property="IsChecked" Value="False"/>

 

        <Setter Property="BorderBrush" Value="Transparent"/>

 

        <Setter Property="BorderThickness" Value="0"/>

 

        <Setter Property="Template">

 

            <Setter.Value>

 

                <ControlTemplate TargetType="ToggleButton">

 

                    <Border x:Name="border"

 

                        Background="{TemplateBinding Background}"

 

    Padding="{TemplateBinding Padding}"

 

    BorderBrush="{TemplateBinding BorderBrush}"

 

    BorderThickness="{TemplateBinding BorderThickness}"

 

    SnapsToDevicePixels="True"

 

                        CornerRadius="3">

 

                        <ContentPresenter Content="{TemplateBinding Content}" VerticalAlignment="Center" HorizontalAlignment="Center"

 

        Focusable="False" RecognizesAccessKey="True"/>

 

                    </Border>

 

                    <ControlTemplate.Triggers>

 

                        <Trigger Property="IsMouseOver" Value="True">

 

                            <Setter TargetName="border" Property="Background" Value="#3F3F3F"/>

 

                        </Trigger>

 

                        <Trigger Property="IsChecked" Value="True">

 

                            <Setter TargetName="border" Property="Background" Value="#595959"/>

 

                        </Trigger>

 

                    </ControlTemplate.Triggers>

 

                </ControlTemplate>

 

            </Setter.Value>

 

        </Setter>

 

    </Style>

 

 

 

</ResourceDictionary>

 

wpf style

---------------------------------------------------------------------------------

 

wpf 的style

原文:https://www.cnblogs.com/bruce1992/p/14851891.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!