Search code examples
c#xamluwpuwp-xamlwindows-10-mobile

Remove Underline from HyperlinkButton in UWP XAML



I need to remove the underline in the content of HyperLinkButton. TextDecorations does 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" />

Solution

  • 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>