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.
Thanks.
"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="https://www.my-company-website.com/privacy-policy/" RequestNavigate="Hyperlink_RequestNavigate">
Privacy Policy
</Hyperlink>
<Run Text=" and "/>
<Hyperlink NavigateUri="https://www.my-company-website.com/terms-and-conditions/" RequestNavigate="Hyperlink_RequestNavigate">
Terms of Use.
</Hyperlink>
</TextBlock>
I think you are looking for the TextAlignment
property. Set this one to Center
:
<TextBlock TextAlignment="Center" ...