Files
Shrlalgo.RvKits/WPFluent/Controls/HyperlinkButton/HyperlinkButton.xaml
ShrlAlgo 4d35cadb56 更新
2025-07-11 09:20:23 +08:00

103 lines
6.5 KiB
XML

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:controls="clr-namespace:WPFluent.Controls"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Thickness x:Key="HyperlinkButtonPadding">11,5,11,6</Thickness>
<Thickness x:Key="HyperlinkButtonBorderThemeThickness">0</Thickness>
<Thickness x:Key="HyperlinkButtonIconMargin">0,0,8,0</Thickness>
<Style TargetType="{x:Type controls:HyperlinkButton}" x:Key="DefaultUiHyperlinkButtonStyle">
<!-- Universal WPF UI focus -->
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
<!-- Universal WPF UI focus -->
<Setter Property="Background" Value="{DynamicResource SubtleFillColorTransparentBrush}" />
<Setter Property="Foreground" Value="{DynamicResource SystemFillColorAttentionBrush}" />
<Setter Property="BorderThickness" Value="{StaticResource HyperlinkButtonBorderThemeThickness}" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="Padding" Value="{StaticResource HyperlinkButtonPadding}" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="Appearance" Value="Accent" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:HyperlinkButton}">
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
Height="{TemplateBinding Height}"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
MinHeight="{TemplateBinding MinHeight}"
MinWidth="{TemplateBinding MinWidth}"
Padding="{TemplateBinding Padding}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
Width="{TemplateBinding Width}"
x:Name="ContentBorder">
<Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ContentControl
Content="{TemplateBinding Icon}"
Focusable="False"
Foreground="{TemplateBinding Foreground}"
Grid.Column="0"
Margin="{StaticResource HyperlinkButtonIconMargin}"
VerticalAlignment="Center"
x:Name="ControlIcon" />
<ContentPresenter
Content="{TemplateBinding Content}"
Grid.Column="1"
TextElement.Foreground="{TemplateBinding Foreground}"
x:Name="ContentPresenter" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="IsPressed" Value="False" />
</MultiTrigger.Conditions>
<Setter Property="Background" TargetName="ContentBorder" Value="{DynamicResource SubtleFillColorSecondaryBrush}" />
<Setter Property="TextElement.Foreground" TargetName="ContentPresenter" Value="{DynamicResource SystemFillColorAttentionBrush}" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="IsPressed" Value="True" />
</MultiTrigger.Conditions>
<Setter Property="Background" Value="{DynamicResource SubtleFillColorTertiaryBrush}" />
<Setter Property="Foreground" TargetName="ControlIcon" Value="{DynamicResource SystemAccentColorTertiaryBrush}" />
<Setter Property="TextElement.Foreground" TargetName="ContentPresenter" Value="{DynamicResource SystemAccentColorTertiaryBrush}" />
</MultiTrigger>
<Trigger Property="Icon" Value="{x:Null}">
<Setter Property="Margin" TargetName="ControlIcon" Value="0" />
<Setter Property="Visibility" TargetName="ControlIcon" Value="Collapsed" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" Value="{DynamicResource SubtleFillColorDisabledBrush}" />
<Setter Property="Foreground" TargetName="ControlIcon" Value="{DynamicResource TextFillColorDisabledBrush}" />
<Setter Property="TextElement.Foreground" TargetName="ContentPresenter" Value="{DynamicResource TextFillColorDisabledBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style BasedOn="{StaticResource DefaultUiHyperlinkButtonStyle}" TargetType="{x:Type controls:HyperlinkButton}" />
</ResourceDictionary>