TextBlock 文本居中问题
TextBlock 文本居中问题
在WPF设计时,设置HorizontalAlignment="Center"时,文本依然靠左显示,这时可以设置Block.TextAlignment="Center",这样文本就会居中显示了。
例如:
<TextBlock Text="操作" Width="80" VerticalAlignment="Center" Block.TextAlignment="Center"/>
在WPF设计时,设置HorizontalAlignment="Center"时,文本依然靠左显示,这时可以设置Block.TextAlignment="Center",这样文本就会居中显示了。
例如:
<TextBlock Text="操作" Width="80" VerticalAlignment="Center" Block.TextAlignment="Center"/>