WPF 纵向文字显示
几种效果:
代码:
<Grid>
<TextBlock Width="100" Height="40" FontSize="30" Text="大家好" Margin="100 0 0 0">
<TextBlock.LayoutTransform>
<RotateTransform Angle="270"></RotateTransform>
</TextBlock.LayoutTransform>
</TextBlock>
<Label x:Name="label" Content="你
好" FontSize="20"/>
<TextBlock TextWrapping="Wrap" Padding="0" LineHeight="0.1" FontSize="20" Width="{Binding RelativeSource={RelativeSource Self},Path=FontSize}" Text="很高兴"/>
</Grid>
或者:
<TextBlock FontSize="30" Text="天
天
好
心
情"></TextBlock>
或者:
Preserve能保留xaml中的空格
<TextBlock xml:space="preserve">
第一行
第二行
</TextBlock>
或者:
<TextBlock Text="{Binding StringFormat='第一行{0}第二行{0}第三行',
Source={x:Static s:Environment.NewLine}}" />