2
我在App.xaml中定义一个样式:奇怪HorizontalContentAlignment(非)行为
<Style x:Key="textBoxCenter" TargetType="{x:Type TextBox}">
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
</Style>
我使用样式中window1.xaml:
<TextBox
Style="{StaticResource textBoxCenter}"
Background="BlanchedAlmond" Text="BobbleHead" />
<TextBox
Style="{StaticResource textBoxCenter}"
Background="AliceBlue" Text="WhammyBar" />
然而,水平对齐,无论是在设计器和在运行时,是'左',即使属性工具栏说它是'中心'。
谢谢你,我还以为HorizontalContentAlignment是我所需要的属性。 – Number8 2009-07-31 15:50:31