fipcurren88 fipcurren88 - 1 month ago 24
C# Question

Remove Underline from HyperlinkButton - XAML

I need to remove underline in this content of HyperLinkButton.
"TextDecorations" not exist in this XAML Element.

<HyperlinkButton x:Name="BtnTeste"
Width="100" Height="50" BorderThickness="1"
HorizontalAlignment="Center"
Foreground="Black" Background="#ffffff"
NavigateUri="www.google.com"
Content="Execute"
/>


Someone help me?
Thanks

Answer

This underline is not exposed inside the HyperlinkButton style. Fortunately, you can easily override its ContentTemplate to get rid of it.

<HyperlinkButton Content="my link">
    <HyperlinkButton.ContentTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding}" />
        </DataTemplate>
    </HyperlinkButton.ContentTemplate>
</HyperlinkButton>