使用WPF中的TextBlock进行字母间距(跟踪)的最佳方式是什么?使用WPF中的TextBlock进行字母间隔(跟踪)?
我会认为TextBlock.Typography会照顾到这一点,但事实并非如此。什么是最好的方法?
使用WPF中的TextBlock进行字母间距(跟踪)的最佳方式是什么?使用WPF中的TextBlock进行字母间隔(跟踪)?
我会认为TextBlock.Typography会照顾到这一点,但事实并非如此。什么是最好的方法?
看来这个问题不容易解决。你可以谷歌并找到像这样的http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/789c3e1b-e3ae-476f-b37f-d93ef6d0cb7b/(带字形的方法)。但是,该字符串枚举集合有时你可以标记解决你的问题是这样考虑到这样的事实:
<Grid>
<ItemsControl>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Rows="1"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemsSource>
<System:String>
Hello World
</System:String>
</ItemsControl.ItemsSource>
</ItemsControl>
</Grid>
调整这个标记(面板,模板),你可以得到字符串的任何所需的布局。当然,你可以将这个标记分开到一个特殊的UserControl。 就像特定情况下的变体一样。
我使用了Kreol建议的方法,发现这样做的工作除了有些字母比其他字母宽。
当使用UniformGrid时,每列的定义都相同。这导致字母之间的可变间距。
相反,我使用水平方向一个StackPanel,并且每个元素的左页边距:
<Grid>
<ItemsControl ItemsSource="{Binding SomeString}" HorizontalAlignment="Center" VerticalAlignment="Center">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="Control.Margin" Value="1,0,0,0"/>
<Setter Property="Control.Foreground" Value="#1E395B"/>
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
</Grid>
也许这会帮助你:http://stackoverflow.com/questions/1476311/wpf-textblock-how -to-均匀空间显示的字符 – torpederos 2011-10-08 21:43:35