WPF,这个对齐方式为什么不听使唤
<Grid HorizontalAlignment="Left" Height="557" VerticalAlignment="Top" Width="483">
<Border Grid.ColumnSpan="2" BorderThickness="0,0,0,2" BorderBrush="SteelBlue">
<TextBlock Text="张三" TextAlignment="Center" HorizontalAlignment="Stretch" />
</Border>
</Grid>
设置了TextBlock填满Border,设置了TextBlock的文本居中,可是结果为什么没有居中呢?
------解决方案--------------------你不是已居中了么?你要的是垂直居中?
------解决方案--------------------VerticalAlignment要选成Center
<Grid>
<Border Grid.ColumnSpan="1" BorderThickness="1" BorderBrush="SteelBlue">
<TextBlock Text="张三" TextAlignment="Center" VerticalAlignment="Center" />
</Border>
</Grid>