ButtonStyle.xaml 9.83 KB
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    >
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/MaterialDesignIcons.xaml"/>
        <ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Colors.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <!--空按钮-->
    <Style TargetType="Button" x:Key="ButtonStyle_empty">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Border 
                        BorderBrush="{TemplateBinding BorderBrush}" 
                        BorderThickness="{TemplateBinding BorderThickness}" 
                        Background="{TemplateBinding Background}" 
                        Height="{TemplateBinding Height}" 
                        Width="{TemplateBinding Width}"
                        >
                        <ContentPresenter RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsKeyboardFocused" Value="true">
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter Property="Opacity" Value="0.5"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
    </Style>

    <Style TargetType="Button" x:Key="ButtonStyle1">
        <Setter Property="Width" Value="150"/>
        <Setter Property="Height" Value="70"/>
        <Setter Property="Margin" Value="6"/>
        <Setter Property="Foreground" Value="#FFFFFFFF" />
        <Setter Property="FontWeight" Value="Bold" />
        <Setter Property="FontSize" Value="36" />
        <Setter Property="FontFamily" Value="YouYuan" />
        <Setter Property="Background" Value="#FF3B3B3B" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <StackPanel Orientation="Vertical">
                        <Border Background="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}">
                            <ContentPresenter HorizontalAlignment="Right" VerticalAlignment="Top" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </Border>
                    </StackPanel>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsKeyboardFocused" Value="true">
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter Property="Opacity" Value="0.5"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="Button" x:Key="ButtonStyle2">
        <Setter Property="Margin" Value="6"/>
        <Setter Property="Width" Value="185"/>
        <Setter Property="Height" Value="85"/>
        <Setter Property="Foreground" Value="#FFFFFFFF" />
        <Setter Property="FontWeight" Value="Bold" />
        <Setter Property="FontSize" Value="48" />
        <Setter Property="FontFamily" Value="YouYuan" />
        <Setter Property="Background" Value="#FF3B3B3B" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <StackPanel Orientation="Vertical">
                        <Border Background="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}">
                            <ContentPresenter RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </Border>
                    </StackPanel>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsKeyboardFocused" Value="true">
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter Property="Opacity" Value="0.5"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Effect">
            <Setter.Value>
                <DropShadowEffect Color="Black" Direction="270" ShadowDepth="3" Opacity="0.4" />
            </Setter.Value>
        </Setter>
        <Setter Property="FlowDirection" Value="LeftToRight" />
    </Style>
    <Style TargetType="Button" x:Key="ButtonStyle3">
        <Setter Property="Foreground" Value="#FFFFFFFF" />
        <Setter Property="FontWeight" Value="Bold" />
        <Setter Property="FontSize" Value="48" />
        <Setter Property="FontFamily" Value="YouYuan" />
        <Setter Property="Background" Value="#FF3B3B3B" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <StackPanel Orientation="Vertical">
                        <Border Background="{TemplateBinding Background}" Height="{TemplateBinding ActualHeight}" Width="{TemplateBinding ActualWidth}">
                            <ContentPresenter RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </Border>
                    </StackPanel>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter Property="Opacity" Value="0.5"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Effect">
            <Setter.Value>
                <DropShadowEffect Color="Black" Direction="270" ShadowDepth="3" Opacity="0.4" />
            </Setter.Value>
        </Setter>
    </Style>

    <!--× √ toggle 按钮-->
    <Style TargetType="{x:Type ToggleButton}" x:Key="ToggleButtonStyle1" >
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Padding" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Canvas Height="45" Width="106">
                        <Path x:Name="Path_Background" Data="F1M1,1C1,1 105,1 105,1 105,1 105,44 105,44 105,44 1,44 1,44 1,44 1,1 1,1z" 
								Fill="#FF008BE5" Height="45" Width="106"/>
                        <Path x:Name="Path_block" Data="F1M1,1C1,1 23,1 23,1 23,1 23,35 23,35 23,35 1,35 1,35 1,35 1,1 1,1z" 
								Fill="#FFFFFFFF" Height="36" Canvas.Left="77" Canvas.Top="5" Width="24"/>
                        <Path x:Name="Path_On" Data="F1M9.551,15.307C9.551,15.307 13.212,23.525 13.212,23.525 13.212,23.525 19.161,6.825 28.542,1.258 28.314,5.234 27.398,8.68 29,12.921 24.881,13.982 16.415,25.91 13.669,31.742 9.78,26.175 5.203,21.934 2,20.609 2,20.609 9.551,15.307 9.551,15.307z" 
							Fill="#FFFFFFFF" Height="33" Canvas.Left="25" Canvas.Top="6" Width="31"/>
                        <Path x:Name="Path_Off" Visibility="Hidden" Data="F1M24.997,23.003C24.997,23.003 15.888,23.003 15.888,23.003 15.888,23.003 12.921,18.001 12.921,18.001 12.921,18.001 9.955,23.003 9.955,23.003 9.955,23.003 1.003,23.003 1.003,23.003 1.003,23.003 7.146,12.303 7.146,12.303 7.146,12.303 1.278,1.997 1.278,1.997 1.278,1.997 10.27,1.997 10.27,1.997 10.27,1.997 13.157,6.801 13.157,6.801 13.157,6.801 15.966,1.997 15.966,1.997 15.966,1.997 24.76,1.997 24.76,1.997 24.76,1.997 18.854,12.303 18.854,12.303 18.854,12.303 24.997,23.003 24.997,23.003z" 
							Fill="#FFFFFFFF" Height="25" Canvas.Left="51" Canvas.Top="10" Width="26"/>
                    </Canvas>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="False">
                            <Setter TargetName="Path_On" Property="Visibility" Value="Hidden"/>
                            <Setter TargetName="Path_Off" Property="Visibility" Value="Visible"/>
                            <Setter TargetName="Path_block" Property="Canvas.Left" Value="4"/>
                            <Setter TargetName="Path_Background" Property="Fill" Value="#FF3B3B3B"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="Path_Background" Property="Opacity" Value="0.7"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    


    <!--button内的阴影-->
    <Style TargetType="Grid" x:Key="GridStyle_ButtonShadow">
        <Setter Property="Effect">
            <Setter.Value>
                <DropShadowEffect BlurRadius="10" RenderingBias="Quality" Color="Black" Direction="270" ShadowDepth="2" Opacity="0.5" />
            </Setter.Value>
        </Setter>
    </Style>
    
</ResourceDictionary>