IconButtonStyle.xaml 7.01 KB
Newer Older
潘栩锋's avatar
潘栩锋 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/BaseStyle.xaml"/>
        <ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/ButtonStyle.xaml"/>
    </ResourceDictionary.MergedDictionaries>
    
    <!--这个文件的生成方式只能选 Page, 不用选resource 不然会提示
    无法从 iconPacks:PackIconMaterial 生成 TargetType -->
    
    
    <!--标准图标按钮 内部为iconPacks的按键,下方可带文字 -->
    <Style TargetType="Button" x:Key="ButtonStyle_icon" BasedOn="{StaticResource ButtonStyle_empty}">
        <Style.Resources>
            <Style TargetType="TextBlock" >
17
                <Setter Property="FontSize" Value="12"/>
潘栩锋's avatar
潘栩锋 committed
18 19
                <Setter Property="Foreground" Value="Black"/>
                <Setter Property="HorizontalAlignment" Value="Center"/>
20
                <Setter Property="TextAlignment" Value="Center"/>
21
                <Setter Property="FontFamily" Value="Microsoft Sans Serif"/>
22
                <Setter Property="Margin" Value="3"/>
潘栩锋's avatar
潘栩锋 committed
23 24
            </Style>
            <Style TargetType="iconPacks:PackIconMaterial" >
25
                <Setter Property="Width" Value="36"/>
潘栩锋's avatar
潘栩锋 committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
                <Setter Property="Height" Value="auto"/>
                <Setter Property="HorizontalAlignment" Value="Center"/>
            </Style>
            
        </Style.Resources>
        <Style.Setters>
            <Setter Property="Foreground" Value="{StaticResource Color_theme_activity}"/>
            <Setter Property="Margin" Value="{StaticResource ControlMargin}"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="HorizontalAlignment" Value="Center"/>
        </Style.Setters>
    </Style>
    <!--小型图标按钮 内部为iconPacks的按键,下方不带文字 -->
    <Style TargetType="Button" x:Key="ButtonStyle_smallIcon" BasedOn="{StaticResource ButtonStyle_empty}">
        <Style.Resources>
            <Style TargetType="iconPacks:PackIconMaterial" >
                <Setter Property="Width" Value="25"/>
                <Setter Property="Height" Value="auto"/>
                <Setter Property="HorizontalAlignment" Value="Center"/>
            </Style>
        </Style.Resources>
        <Style.Setters>
            <Setter Property="Foreground" Value="{StaticResource Color_theme_activity}"/>
            <Setter Property="Margin" Value="{StaticResource ControlMargin}"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="HorizontalAlignment" Value="Center"/>
        </Style.Setters>
    </Style>
    <!--大型图标按钮 内部为iconPacks的按键,下方可带文字 -->
    <Style TargetType="Button" x:Key="ButtonStyle_largeIcon" BasedOn="{StaticResource ButtonStyle_empty}">
        <Style.Resources>
            <Style TargetType="TextBlock" >
                <Setter Property="FontSize" Value="18"/>
                <Setter Property="Foreground" Value="Black"/>
                <Setter Property="HorizontalAlignment" Value="Center"/>
            </Style>
            <Style TargetType="iconPacks:PackIconMaterial" >
                <Setter Property="Width" Value="50"/>
                <Setter Property="Height" Value="auto"/>
                <Setter Property="HorizontalAlignment" Value="Center"/>
            </Style>
        </Style.Resources>
        <Style.Setters>
            <Setter Property="Foreground" Value="{StaticResource Color_theme_activity}"/>
            <Setter Property="Margin" Value="{StaticResource ControlMargin}"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="HorizontalAlignment" Value="Center"/>
        </Style.Setters>
    </Style>


    <!--圆形确定按钮,绿色, 很多界面使用,例如扫描图 设置界面 -->
    <Style x:Key="ButtonStyle_apply" TargetType="Button" BasedOn="{StaticResource ButtonStyle_empty}">
        <Setter Property="Foreground" Value="#FF31AE15"/>
        <Setter Property="Margin" Value="{StaticResource ControlMargin}"/>
        <Setter Property="HorizontalAlignment" Value="Right"/>
        <Setter Property="VerticalAlignment" Value="Top"/>
        <Setter Property="Content">
            <Setter.Value>
                <Grid>
                    <Ellipse Fill="White" Height="90" Width="90"/>
                    <iconPacks:PackIconMaterial Kind="CheckCircle" HorizontalAlignment="Center" VerticalAlignment="Center" Width="80" Height="auto" />
                </Grid>
            </Setter.Value>
        </Setter>
    </Style>

    <!--矩形图标按钮 内部为iconPacks的按键,下方不可带文字 -->
    <Style TargetType="Button" x:Key="ButtonStyle_RectangleIcon">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid Style="{StaticResource GridStyle_ButtonShadow}">
                        <Border 
                                        BorderBrush="{TemplateBinding BorderBrush}" 
                                        BorderThickness="{TemplateBinding BorderThickness}" 
                                        Background="{TemplateBinding Background}" 
                                        Height="40" 
                                        Width="40"
                                        >
                            <ContentPresenter RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </Border>
                    </Grid>
                    <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="{StaticResource Color_theme_activity}"/>
        <Setter Property="Foreground" Value="{StaticResource Color_theme_background}"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="Margin" Value="{StaticResource ControlMargin}"/>
        <Style.Resources>
            <Style TargetType="iconPacks:PackIconMaterial" >
                <Setter Property="Width" Value="20"/>
                <Setter Property="Height" Value="auto"/>
                <Setter Property="VerticalAlignment" Value="Center"/>
                <Setter Property="HorizontalAlignment" Value="Center"/>
            </Style>
        </Style.Resources>
    </Style>
</ResourceDictionary>