chr
2024-08-07 22beee93f14d042aa184148c53efb79e23416526
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <FontFamily x:Key="iconfont">
        /PdmSwPlugin.Common;component/Image/IconFont/#iconfont
    </FontFamily>
 
    <ControlTemplate  x:Key="toolbarButtom" TargetType="{x:Type ButtonBase}">
        <Button Content="{TemplateBinding Content}" Width="{TemplateBinding Width}" Height="30">
            <Button.Style>
                <Style TargetType="{x:Type Button}" >
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type ButtonBase}">
                                <Border Background="{TemplateBinding Background}">
                                    <Grid>
                                        <Border x:Name="bottom" BorderThickness="0,0,2,2" BorderBrush="DimGray" 
                                                                    CornerRadius="{Binding ElementName=button, Path=CornerRadius}">
                                            <Border.Effect>
                                                <BlurEffect Radius="0" KernelType="Gaussian"/>
                                            </Border.Effect>
                                        </Border>
                                        <Border x:Name="top" BorderThickness="2,2,0,0" BorderBrush="White" Opacity="0.3"
                                                                    CornerRadius="{Binding ElementName=button, Path=CornerRadius}">
                                            <Border.Effect>
                                                <BlurEffect Radius="0" KernelType="Gaussian"/>
                                            </Border.Effect>
                                        </Border>
 
                                        <Border  BorderThickness="5,0" BorderBrush="Transparent" >
                                            <ContentPresenter TextBlock.FontSize="{TemplateBinding FontSize}" 
              TextBlock.FontFamily="{StaticResource iconfont}" 
              TextBlock.Foreground="{TemplateBinding Foreground}" 
              VerticalAlignment="Center" 
              HorizontalAlignment="Center"
              Content="{TemplateBinding Content}"/>
                                        </Border>
                                        
                                    </Grid>
                                </Border>
                                <ControlTemplate.Triggers>
                                    <Trigger Property="IsMouseOver" Value="True">
                                        <Setter TargetName="bottom" Property="BorderBrush" Value="LightGray"/>
                                        <Setter TargetName="bottom" Property="Opacity" Value="0.3"/>
 
                                        <Setter TargetName="top" Property="BorderBrush" Value="DimGray"/>
                                        <Setter TargetName="top" Property="Opacity" Value="1"/>
                                    </Trigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Button.Style>
        </Button>
    </ControlTemplate>
    
 
    <!--按钮浮雕效果-->
    <Style x:Key="CommonToolBar" TargetType="{x:Type ToolBar}">
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToolBar}">
                    <ToolBarPanel IsItemsHost="true" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Margin" Value="0,0,0,2"/>
 
        <Style.Resources>
            <Style x:Key="{x:Static ToolBar.ButtonStyleKey}" TargetType="Button">
                <Setter Property="Padding" Value="20"/>
                <Setter Property="MinWidth" Value="30"/>
                <Setter Property="Template" Value="{StaticResource toolbarButtom}"/>
            </Style>
        </Style.Resources>
    </Style>
</ResourceDictionary>