fix template

This commit is contained in:
qile.wang 2024-03-06 19:21:48 +08:00
parent 8dee3ec364
commit 801fea8269

View File

@ -15,26 +15,48 @@
<Setter Property="Background" Value="{DynamicResource HyperlinkButtonDefaultBackground}" /> <Setter Property="Background" Value="{DynamicResource HyperlinkButtonDefaultBackground}" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate TargetType="HyperlinkButton"> <ControlTemplate TargetType="HyperlinkButton">
<ContentPresenter <Grid ColumnDefinitions="Auto,*" x:Name="RootGrid">
Background="{TemplateBinding Background}" <Grid
Content="{TemplateBinding Content}" Grid.Column="0"
ContentTemplate="{TemplateBinding ContentTemplate}" IsVisible="False"
Cursor="{TemplateBinding Cursor}" VerticalAlignment="Center"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" x:Name="IconGrid">
Padding="{TemplateBinding Padding}" <Border
RecognizesAccessKey="True" Background="{DynamicResource HyperlinkButtonDefaultBackground}"
TextElement.FontFeatures="{TemplateBinding FontWeight}" Height="{DynamicResource HyperlinkButtonIconHeight}"
TextElement.FontSize="{TemplateBinding FontSize}" Opacity="0"
TextElement.FontWeight="{TemplateBinding FontWeight}" UseLayoutRounding="False"
UseLayoutRounding="False" Width="{DynamicResource HyperlinkButtonIconWidth}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" x:Name="BackgroundRectangle" />
x:Name="PART_ContentPresenter" /> <PathIcon
Data="{DynamicResource HyperlinkButtonLinkGlyph}"
Foreground="{DynamicResource HyperlinkButtonForeground}"
Height="{DynamicResource HyperlinkButtonLinkGlyphHeight}"
Name="LinkGlyph"
VerticalAlignment="Center"
Width="{DynamicResource HyperlinkButtonLinkGlyphWidth}" />
</Grid>
<ContentPresenter
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Cursor="{TemplateBinding Cursor}"
Grid.Column="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Padding="8,0,0,0"
RecognizesAccessKey="True"
VerticalAlignment="Center"
x:Name="ContentPresenter" />
</Grid>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
<!-- Unvisited Pointerover State -->
<Style Selector="^:pointerover"> <Style Selector="^:pointerover">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonOverForeground}" /> <Style Selector="^ /template/ PathIcon#LinkGlyph">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonOverForeground}" />
</Style>
<Style Selector="^ /template/ ContentPresenter#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonOverForeground}" />
</Style>
</Style> </Style>
<!-- Unvisited Pressed State --> <!-- Unvisited Pressed State -->
@ -44,15 +66,30 @@
<!-- Unvisited Disabled state --> <!-- Unvisited Disabled state -->
<Style Selector="^:disabled"> <Style Selector="^:disabled">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonDisabledForeground}" /> <Style Selector="^ /template/ PathIcon#LinkGlyph">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonDisabledForeground}" />
</Style>
<Style Selector="^ /template/ ContentPresenter#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonDisabledForeground}" />
</Style>
</Style> </Style>
<Style Selector="^:visited"> <Style Selector="^:visited">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonVisitedForeground}" /> <Style Selector="^ /template/ PathIcon#LinkGlyph">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonVisitedForeground}" />
</Style>
<Style Selector="^ /template/ ContentPresenter#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonVisitedForeground}" />
</Style>
<!-- Visited Pointerover State --> <!-- Visited Pointerover State -->
<Style Selector="^:pointerover"> <Style Selector="^:pointerover">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonOverForeground}" /> <Style Selector="^ /template/ PathIcon#LinkGlyph">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonOverForeground}" />
</Style>
<Style Selector="^ /template/ ContentPresenter#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonOverForeground}" />
</Style>
</Style> </Style>
<!-- Visited Pressed State --> <!-- Visited Pressed State -->
@ -62,100 +99,18 @@
<!-- Visited Disabled State --> <!-- Visited Disabled State -->
<Style Selector="^:disabled"> <Style Selector="^:disabled">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonDisabledForeground}" /> <Style Selector="^ /template/ PathIcon#LinkGlyph">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonDisabledForeground}" />
</Style>
<Style Selector="^ /template/ ContentPresenter#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonDisabledForeground}" />
</Style>
</Style> </Style>
</Style> </Style>
<Style Selector="^.WithIcon"> <Style Selector="^.WithIcon">
<Setter Property="Template"> <Style Selector="^ /template/ Grid#IconGrid">
<ControlTemplate TargetType="HyperlinkButton"> <Setter Property="IsVisible" Value="True" />
<Grid ColumnDefinitions="Auto,*" x:Name="RootGrid">
<Grid Grid.Column="0" VerticalAlignment="Center">
<Border
Background="{DynamicResource HyperlinkButtonDefaultBackground}"
Height="{DynamicResource HyperlinkButtonIconHeight}"
Opacity="0"
UseLayoutRounding="False"
Width="{DynamicResource HyperlinkButtonIconWidth}"
x:Name="BackgroundRectangle" />
<PathIcon
Data="{DynamicResource HyperlinkButtonLinkGlyph}"
Foreground="{DynamicResource HyperlinkButtonForeground}"
Height="{DynamicResource HyperlinkButtonLinkGlyphHeight}"
Name="LinkGlyph"
VerticalAlignment="Center"
Width="{DynamicResource HyperlinkButtonLinkGlyphWidth}" />
</Grid>
<ContentPresenter
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Cursor="{TemplateBinding Cursor}"
Grid.Column="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Padding="8,0,0,0"
RecognizesAccessKey="True"
VerticalAlignment="Center"
x:Name="ContentPresenter" />
</Grid>
</ControlTemplate>
</Setter>
<!-- Unvisited Pointerover State -->
<Style Selector="^:pointerover">
<Style Selector="^ /template/ PathIcon#LinkGlyph">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonOverForeground}" />
</Style>
<Style Selector="^ /template/ ContentPresenter#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonOverForeground}" />
</Style>
</Style>
<!-- Unvisited Pressed State -->
<Style Selector="^:pressed">
<Setter Property="RenderTransform" Value="scale(0.98)" />
</Style>
<!-- Unvisited Disabled state -->
<Style Selector="^:disabled">
<Style Selector="^ /template/ PathIcon#LinkGlyph">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonDisabledForeground}" />
</Style>
<Style Selector="^ /template/ ContentPresenter#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonDisabledForeground}" />
</Style>
</Style>
<Style Selector="^:visited">
<Style Selector="^ /template/ PathIcon#LinkGlyph">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonVisitedForeground}" />
</Style>
<Style Selector="^ /template/ ContentPresenter#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonVisitedForeground}" />
</Style>
<!-- Visited Pointerover State -->
<Style Selector="^:pointerover">
<Style Selector="^ /template/ PathIcon#LinkGlyph">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonOverForeground}" />
</Style>
<Style Selector="^ /template/ ContentPresenter#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonOverForeground}" />
</Style>
</Style>
<!-- Visited Pressed State -->
<Style Selector="^:pressed">
<Setter Property="RenderTransform" Value="scale(0.98)" />
</Style>
<!-- Visited Disabled State -->
<Style Selector="^:disabled">
<Style Selector="^ /template/ PathIcon#LinkGlyph">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonDisabledForeground}" />
</Style>
<Style Selector="^ /template/ ContentPresenter#ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonDisabledForeground}" />
</Style>
</Style>
</Style> </Style>
</Style> </Style>
</ControlTheme> </ControlTheme>