How can I center align text with hyperlinks in it?

Stout 286 Reputation points

Hi. How can I center align text with hyperlinks in it?

I need to have the some text below, and with the XAML I got it's currently not centered. In fact, Horizontal Alignment does not seem to have any effect. Hyperlinks are working fine, however.

This is inside a grid with 2 columns, and I need the ColumnSpan to be 2.


"By clicking Sign In, you agree to our [HYPERLINK: Privacy Policy] and [HYPERLINK: Terms of Use.]"

    <TextBlock Grid.Row="3" Grid.ColumnSpan="2" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White" FontSize="18px">
        <Run Text="By clicking Sign In, you agree to our " /> 
        <Hyperlink NavigateUri="" RequestNavigate="Hyperlink_RequestNavigate">
            Privacy Policy
        <Run Text=" and "/>
        <Hyperlink NavigateUri="" RequestNavigate="Hyperlink_RequestNavigate">
            Terms of Use.
Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,701 questions
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
778 questions
0 comments No comments
{count} votes

Accepted answer
  1. Stout 286 Reputation points

    Someone just told me that HorizontalAlignment is for the entire TextBlock control, whereas TextAlignment is for the actual text content. So:

    <TextBlock TextAlignment="Center" ...
    0 comments No comments

0 additional answers

Sort by: Most helpful