TextBlock默认文本是居上的,像是这样子

WPF TextBlock控件文本垂直居中或居下_垂直居中

 

 但是TextBlock空间没有VerticalContentAlignment属性,无法设置文本垂直居中,

所以改用Label控件,效果实现

<Label VerticalContentAlignment="Center" Padding="0" Height="100" Background="red" x:Name="Num" Foreground="LightGreen" VerticalAlignment="Bottom" HorizontalAlignment="Center" >001</Label>

WPF TextBlock控件文本垂直居中或居下_垂直居中_02