Repository navigation
Open
Labels
Description
Description
We have the light/dark resources for HyperlinkButton already but they are unused. I realize there is no HyperlinkButton in WPF but we can do what is done with AccentButtonStyle in this case.
Reproduction Steps
See Fluent Theme
Expected behavior
It would be ideal to pull this style into the Fluent theme. It is based on AccentButtonStyle and uses the already existing HyperlinkButton* resources.
<Style
x:Key="HyperlinkButtonStyle"
TargetType="{x:Type Button}">
<Setter Property="Focusable" Value="False" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="Background" Value="{DynamicResource HyperlinkButtonBackground}" />
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonForeground}" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Padding" Value="{StaticResource ButtonPadding}" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="m:ControlHelper.CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate
TargetType="{x:Type Button}">
<Border
x:Name="ContentBorder"
Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}"
MinWidth="{TemplateBinding MinWidth}"
MinHeight="{TemplateBinding MinHeight}"
Padding="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding m:ControlHelper.CornerRadius}">
<TextBlock
x:Name="ContentTextBlock"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Foreground="{TemplateBinding Foreground}"
Text="{TemplateBinding Content}"
TextAlignment="Center"
TextDecorations="Underline" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource HyperlinkButtonBackgroundPointerOver}" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource HyperlinkButtonBackgroundPressed}" />
<Setter TargetName="ContentTextBlock" Property="Foreground" Value="{DynamicResource HyperlinkButtonForegroundPressed}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource HyperlinkButtonBackgroundDisabled}" />
<Setter TargetName="ContentTextBlock" Property="Foreground" Value="{DynamicResource HyperlinkButtonForegroundDisabled}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>Actual behavior
Nothing is shown -- or -- the default .ToString() is shown.
Regression?
No response
Known Workarounds
No response
Impact
No response
Configuration
No response
Other information
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
harshit7962 commentedon May 27, 2025
@robert-abeo as you mentioned, WPF does not provide a
HyperlinkButton. From a framework point of view, it seems unnecessary to provide a style that is not consumed within the framework. To address your point that these resources are defined in Dark/Light themes, since they are part of .NET 9, they are kind of an API contract now. Removing them might lead to breaking changes. Additionally, having these resources simply helps developers create aHyperlinkButtonmuch like you have demonstrated.harshit7962 commentedon May 29, 2025
@robert-abeo if you agree with the reasoning here, can we close this issue?
robert-abeo commentedon May 29, 2025
@harshit7962
My points are:
It seems you are missing an opportunity here. And I would argue this really isn't much of a maintenance burden either since we already have resources imported from WinUI to use here.