<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/Dictionary_MyStyle.xaml"/> </ResourceDictionary.MergedDictionaries> <SolidColorBrush x:Key="Color_background" Color="#FFf1f1f1"/> <!--点击事件 被按下去的感觉--> <Style TargetType="Button" x:Key="Styles.Button.ResizeIcon"> <Style.Resources> <Style TargetType="iconPacks:PackIconMaterial"> <Setter Property="Width" Value="auto"/> <Setter Property="Height" Value="auto"/> <Setter Property="HorizontalAlignment" Value="Center"/> <Setter Property="VerticalAlignment" Value="Center"/> </Style> </Style.Resources> <Setter Property="Foreground" Value="{StaticResource Brushes.Static}"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Border Background="Transparent"> <Grid x:Name="grid" Style="{StaticResource Styles.Shadow}"> <ContentPresenter x:Name="path" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Width="50" Height="{Binding RelativeSource={RelativeSource Mode=Self},Path=Width}" HorizontalAlignment="Center" VerticalAlignment="Center" /> </Grid> </Border> <ControlTemplate.Triggers> <!--鼠标移动 透明度变为70%--> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Opacity" Value="0.7"/> </Trigger> <!--点击事件 内容变小 50变为46,阴影效果取消, 效果就是 被按下去的感觉--> <Trigger Property="IsPressed" Value="True"> <Setter TargetName="path" Property="Width" Value="46"/> <Setter TargetName="grid" Property="Margin" Value="2"/> <Setter Property="Foreground" Value="{StaticResource Brushes.Activity}"/> <Setter TargetName="grid" Property="Effect" Value="{x:Null}" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> <!--手动按钮--> <Style TargetType="{x:Type ToggleButton}" x:Key="ToggleButtonStyle_hand" > <Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="Padding" Value="1"/> <Setter Property="Foreground" Value="{StaticResource Brushes.Static}"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ToggleButton}"> <Grid x:Name="grid" HorizontalAlignment="Center"> <iconPacks:PackIconMaterial x:Name="path" Kind="HandRight" Width="50" Height="auto"/> <TextBlock x:Name="blocka" Text="A" Foreground="Red" HorizontalAlignment="Right" VerticalAlignment="Bottom" FontSize="30" Margin="0,0,0,-10" Visibility="Hidden"/> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Opacity" Value="0.7"/> </Trigger> <Trigger Property="IsPressed" Value="True"> <Setter TargetName="path" Property="Width" Value="46"/> <Setter TargetName="grid" Property="Margin" Value="2"/> <Setter Property="Foreground" Value="{StaticResource Brushes.Activity}"/> </Trigger> <Trigger Property="IsChecked" Value="True"> <Setter TargetName="blocka" Property="Visibility" Value="Visible"/> <Setter Property="Foreground" Value="{StaticResource Brushes.Activity}"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> <!--手动按钮的文字--> <Style TargetType="TextBlock" x:Key="TextBlockStyle_hand" BasedOn="{StaticResource Styles.Text.FieldHeader}"> <Setter Property="Text" Value="抓手手动"/> <Style.Triggers> <DataTrigger Binding="{Binding Tag,RelativeSource={RelativeSource Mode=Self}}" Value="True"> <Setter Property="Text" Value="抓手自动"/> </DataTrigger> </Style.Triggers> </Style> </ResourceDictionary>