UWP如何在ContentPresenter中设置文本对齐方式

时间:2016-06-22 04:02:18

标签: xaml uwp

wrapped text will keep center not left

有没有办法设置文本换行,以便文本块中的所有文本都是居中对齐的?

 <ContentPresenter        x:Name="CPMessage"
                                      Content="{Binding BodyContent, ElementName=control, Mode=OneWay}"
                                      Margin="32,0,32,36"
                                      TextWrapping="WrapWholeWords"
                                      HorizontalAlignment="Center"
                                      VerticalAlignment="Top"
                                      HorizontalContentAlignment="Center"
                                      VerticalContentAlignment="Center"
                                      FontSize="16" />

1 个答案:

答案 0 :(得分:1)

使用以下代码

轻松修复了它
<TextBlock Text="{Binding BodyContent, ElementName=control, Mode=OneWay}"
                                   TextWrapping="WrapWholeWords"
                                   TextAlignment="Center" />

在COntentPresenter中添加代码