调整页面标题

本文关键字:标题 调整 | 更新日期: 2023-09-27 18:04:00

这可能是一个相当简单的问题,但很难谷歌!我从外部内容加载我的标题,所以有时它会比别人长。我想要的是字体自动调整大小,使其适合页面。什么好主意吗?

        <controls:PivotItem Name="Header" Header="some string that can be long" FontStretch="ExtraCondensed">

调整页面标题

最简单的方法是使用转换器将字符串长度转换为字体长度/字体大小:

   <controls:PivotItem Name="Header" Header="{Binding theString}" 
         FontStretch="{Binding thestring, Converter={StaticResource stringToFontStretchConverter}}" 
         FontSize="{Binding thestring, Converter={StaticResource stringToFontSizeConverter}}">

虽然从设计的角度来看,我不会改变字体取决于字符串的长度

你应该使用ViewBox控件并在其中放置Container控件。

参考:http://blogs.imeta.co.uk/nrees/archive/2010/06/29/viewbox-wrappanel-and-a-scalable-ui-for-windows-phone-7.aspx