2025-03-28 09:49:56 +08:00

40 lines
3.0 KiB
XML

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:HiiSheWpf="clr-namespace:HiiShe.WPFUI.Controls" >
<Style x:Key="{x:Type HiiSheWpf:HSImageButton}" TargetType="{x:Type HiiSheWpf:HSImageButton}">
<Setter Property="Control.VerticalContentAlignment" Value="Stretch" />
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type HiiSheWpf:HSImageButton}">
<Grid Name="templateRoot" SnapsToDevicePixels="True" Width="{TemplateBinding FrameworkElement.Width}" Height="{TemplateBinding FrameworkElement.Height}" Background="#00FF0000">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="20" />
</Grid.RowDefinitions>
<Border Name="mainBorder" BorderThickness="1,1,1,0" Margin="0" Grid.RowSpan="1" Background="{TemplateBinding Control.Background}" Width="48" Height="48" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5" />
<ContentPresenter Name="contentPresenter"
ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
Content="{TemplateBinding ContentControl.Content}"
ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}"
ContentSource="Content"
Focusable="False"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"
Grid.Row="1" HorizontalAlignment="Center"
VerticalAlignment="Top"
TextElement.Foreground="{TemplateBinding Control.Foreground}" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="UIElement.IsMouseOver" Value="True">
<Setter TargetName="templateRoot" Value="{Binding MyMoverBrush, RelativeSource={RelativeSource TemplatedParent}}" Property="Border.Background" />
</Trigger>
<Trigger Property="ButtonBase.IsPressed" Value="True">
<Setter TargetName="templateRoot" Value="{Binding MyEnterBrush, RelativeSource={RelativeSource TemplatedParent}}" Property="Border.Background" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>