Skip to content

Fluent2: Missing HyperlinkButtonStyle #10369

Open

Description

@robert-abeo

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

Activity

  1. self-assigned this
    on May 27, 2025
  2. harshit7962 commented on May 27, 2025

    @harshit7962
    Member

    @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 a HyperlinkButton much like you have demonstrated.

  3. harshit7962 commented on May 29, 2025

    @harshit7962
    Member

    @robert-abeo if you agree with the reasoning here, can we close this issue?

  4. added
    📭 waiting-author-feedback
    on May 29, 2025
  5. robert-abeo commented on May 29, 2025

    @robert-abeo
    Author

    @harshit7962

    From a framework point of view, it seems unnecessary to provide a style that is not consumed within the framework.

    My points are:

    1. We already have precedence for this. The accent button style is the exact same scenario. It isn't it's own control but is a very useful variant of the button style for modern applications.
    2. Just like the accent button, a Hyperlink button style is very useful for modern applications. Almost all applications have a hyperlink these days.

    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.

  6. removed
    📭 waiting-author-feedback
    on May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions