我想动态调整标签内容;当文本较大时,调整标签fontsize以适合标签空间。
<Label Name="lblResult" Content="0" Margin="0,-1,-222,0" VerticalAlignment="Top"
HorizontalContentAlignment="Right" VerticalContentAlignment="Bottom"
FontFamily="Helvetica Neue" Foreground="White" Background="Black"
Height="87" FontSize="63" RenderTransformOrigin="0.5,0.5" Padding="9"
ContentStringFormat="{}{0:#,0}" FontWeight="Light" ClipToBounds="True" />
谢谢
答案 0 :(得分:0)
WPF Viewbox控件会将其内容增大/缩小到可用空间:
http://www.wpftutorial.net/ViewBox.html
只需将您的标签放在ViewBox中:
<Viewbox Stretch="Uniform">
<Label Name="lblResult" Content="Moez Rebai" VerticalAlignment="Top"
HorizontalContentAlignment="Right" VerticalContentAlignment="Bottom"
FontFamily="Helvetica Neue" Foreground="White" Background="Black"
Height="87" FontSize="63" RenderTransformOrigin="0.5,0.5" Padding="9"
ContentStringFormat="{}{0:#,0}" FontWeight="Light" ClipToBounds="True" />
</Viewbox>
当然,您的Viewbox通常按容器缩放,但希望您明白这一点!