Xamarin.forms 如何在标签中居中放置多行文字

Xamarin.forms 如何在标签中居中放置多行文字,xamarin.forms,Xamarin.forms,是否有人知道如何使用LineBreakMode=WordWrap将Xamarin表单标签中的文本居中(或对齐或以任何方式水平效果)?不使用WebView(或类似工具) 在此代码段中,所有horizontalpoptions条目都被愉快地忽略了: <StackLayout> <Label Margin="75,0,75,0" FontAttributes="Italic" FontSize="Large" H

是否有人知道如何使用
LineBreakMode=WordWrap
将Xamarin表单标签中的文本居中(或对齐或以任何方式水平效果)?不使用WebView(或类似工具)

在此代码段中,所有
horizontalpoptions
条目都被愉快地忽略了:

<StackLayout>
    <Label
        Margin="75,0,75,0"
        FontAttributes="Italic"
        FontSize="Large"
        HorizontalOptions="Center"
        LineBreakMode="WordWrap"
        Text="Live life as though nobody is watching, and express yourself as though everyone Is listening."
        VerticalOptions="CenterAndExpand" />
</StackLayout>


看起来是这样的。

在这种情况下,您应该使用HorizontalTextAlignment=“Center”

<StackLayout>
    <Label
        Margin="75,0,75,0"
        FontAttributes="Italic"
        FontSize="Large"
        HorizontalOptions="Center"
        HorizontalTextAlignment="Center"
        LineBreakMode="WordWrap"
        Text="Live life as though nobody is watching, and express yourself as though everyone Is listening."
        VerticalOptions="CenterAndExpand" />
</StackLayout>

在代码中添加此行

HorizontalTextAlignment=“中心”



使用
HorizontalTextAlignment
Neat引用此尝试。我想这是有道理的,因为
水平选项
只与
标签
在父项中的位置有关,对吗?谢谢
<StackLayout>
    <Label
        Margin="75,0,75,0"
        FontAttributes="Italic"
        FontSize="Large"
        HorizontalOptions="Center"
        HorizontalTextAlignment="Center"
        LineBreakMode="WordWrap"
        Text="Live life as though nobody is watching, and express yourself as though everyone Is listening."
        VerticalOptions="CenterAndExpand" />
</StackLayout>