我的XAML-Page中有多个TextBox。
<TextBox Name="TxtCompanyId" PlaceholderText="FirmaId" Height="40" Margin="5" TextAlignment="Center" />
TextAlignment =“Center”属性仅使TextBox的文本居中,而不是placeholdertext / hint文本。有没有办法让两者兼顾?
答案 0 :(得分:8)
您肯定可以修改defalut样式并将 PlaceholderTextContentPresenter的水平对齐设置为 Center :
item
完整修改后的风格:
<ContentControl x:Name="PlaceholderTextContentPresenter" Grid.ColumnSpan="2" Content="{TemplateBinding PlaceholderText}" Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}" IsHitTestVisible="False" IsTabStop="False" Margin="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" Grid.Row="1" HorizontalAlignment="Center"/>