使用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