wpf textblock 文字间距设置

温文洲 2012-12-17 04:50:01
请问在wpf textblock 文字间距怎样设置,不如textBlock的text为“Hello”
我想得到“H e l l o”的效果,不要告诉我用空格哦,因为我是绑定的,呵呵
...全文
3669 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
gqqnb 2012-12-18
  • 打赏
  • 举报
回复
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<ItemsControl ItemsSource="{Binding Path=Title, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Margin="5">
<ContentPresenter Content="{Binding}"/>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Window>




这个方案的特点是你不用(也不能)单独设置每个字符间距了,任何相邻字符的间距都是固定的(在这里是5)。

这个方案不是用TextBlock。TextBlock比较轻量嘛。
gqqnb 2012-12-18
  • 打赏
  • 举报
回复
我想到了几个方案,分别给你回复。

可以用http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/789c3e1b-e3ae-476f-b37f-d93ef6d0cb7b/ 所建议的方法,用Glyphs.Indices属性

        <Glyphs
UnicodeString = "Wide load!"
Indices = ",150;,100;,100;,100;,100;,100;,100;,100;,100;"
FontUri = "file://c:/windows/fonts/times.ttf"
Fill = "Black"
FontRenderingEmSize = "40"
/>


在路上20130607 2012-12-18
  • 打赏
  • 举报
回复
可以在binding 的时候 写个convert
温文洲 2012-12-18
  • 打赏
  • 举报
回复
各位大侠,谁能帮帮我呀?
Bonjour-你好 2012-12-18
  • 打赏
  • 举报
回复
Silverlight 5 的TextBlock控件有个CharacterSpacing属性,不知SL的控件能不能用在Wpf上
温文洲 2012-12-18
  • 打赏
  • 举报
回复
引用 4 楼 gqqnb 的回复:
C# code?12345678910111213141516171819<Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.m……
这个方案应该可行,我也是上午刚想到了一个就是用pathlistBox,跟你这个很像,但就像你说的每个字符间距都是固定的且一样的。 谢谢你的建议。
温文洲 2012-12-18
  • 打赏
  • 举报
回复
引用 2 楼 luoSaiMingJavaAndC 的回复:
可以在binding 的时候 写个convert
这个方案想过,但是在convert中还得加入空格,很是麻烦。 但还是谢谢你。

8,756

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧