xaml - 如何在 Universal Windows Phone 的 TextBox 中将文本对齐为中心?

标签 xaml win-universal-app

我有一个文本框,我已将 Horizo​​ntalAlignment、VerticalAlignment、Horizo​​ntalContentAlignment、VerticalContentAlignment 和 TextAlignment 设置为中心 但文本未居中对齐。请引用下面的代码示例和图片

<TextBox Text="Farjana" Width="200" Height="100" TextAlignment="Center"
        HorizontalAlignment="Center" VerticalAlignment="Center"
        HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>

enter image description here

如何将此文本居中对齐?

最佳答案

TextAlignment="Center"

<TextBox TextAlignment="Center"  Height="100" />

更新

<Border BorderThickness="2" BorderBrush="Black" Width="200" Height="100" >
            <TextBox BorderThickness="0" Margin="70,0,0,0"  Text="Farjana" TextWrapping="Wrap"        
           />
        </Border>

enter image description here

关于xaml - 如何在 Universal Windows Phone 的 TextBox 中将文本对齐为中心?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37157531/

相关文章:

wpf - DataTemplate 似乎没有绑定(bind)

c# - 如何为 UAP 拍摄媒体元素的当前帧(Windows 10)

c# - XAML Windows 通用应用程序的全局命令栏

xaml - Windows Phone工具包ListPicker只允许5个元素

c# - Xaml CloseButtonText 给出 InvalidCastException

c# - 在 WPF/C# 中以编程方式更改边距

wpf - 填充StackPanel中的所有可用空间

c# - 动态添加网格 UWP

c# - Windows 8.1 通用应用引用

c# - Windows 8.1 应用程序中的事件日志记录