是否有可能"变焦"在WPF RichTextBox的文本? [英] Is it possible to "zoom" the text in a WPF RichTextBox?
问题描述
我注意到的WinForms RichTextBox中有我想正是我想要什么 ZoomFactor
属性 - 不幸的是,这似乎在WPF变种完全丢失。
I noticed the WinForms RichTextBox has a ZoomFactor
property that I assume is exactly what I want--unfortunately this seems to be entirely missing on the WPF variant.
有没有什么办法可以实现相同的功能(增加/减少整个文件的可见文本大小没有实际改变底层RTF)?
Is there any way I can achieve the same functionality (increasing/decreasing the visible text size of the whole document without actually changing the underlying RTF)?
更新:虽然关于RichTextBox的设置LayoutTransform似乎在非常简单的设置工作,它不完全等同于设置的,因为有两件事情ZoomFactor:
Update: While setting a LayoutTransform on the RichTextBox does seem to work under very simple settings, it's not exactly the same as setting ZoomFactor because of a couple things:
- 首先,滚动条也被放大。这只是看起来很傻
- 其次,在我的应用程序(出于某种原因,但不是在Kaxaml - I'll探索这个找出原因),文字的的位图缩放的,以便它只是扩大,而不是呈现的文本矢量缩放它所以它是平滑的。这里就是我说的(注意方式,大的自定义滚动条)的例子:
- First, the scroll bar is zoomed also. This just looks silly.
- Second, in my app (for some reason, but not in Kaxaml--I'll explore this to figure out why), the text is bitmap zoomed so that it just enlarges the rendered text as opposed to vector-zooming it so it's smooth. Here's an example of what I'm talking about (note the way-big custom scroll bar):
更新2:好我发现,缩放,位图正在被设定为TextOptions.TextFormattingMode 显示的
而不是理想
引起的。将其设置为理想的载体重新引入变焦。
Update 2: Okay I discovered that the bitmap zooming was being caused by setting TextOptions.TextFormattingMode to Display
instead of Ideal
. Setting it to ideal reintroduces vector zooming.
不过还是有那个讨厌的滚动条!我的意思是一种选择是在RichTextBox中禁用滚动,并在包装的ScrollViewer,但我不知道这是否会降低性能。我也想知道,如果我这样做,文字换行,仍能正常工作
However there is still that pesky scroll bar! I mean one option is to disable scrolling on the RichTextBox and wrap it in a ScrollViewer, but I wonder if that would deteriorate performance. I also wonder if text wrapping would still work if I did that.
推荐答案
这应该让你开始:
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<DockPanel LastChildFill="True">
<Slider x:Name="Scale" DockPanel.Dock="Bottom" Minimum="1" Maximum="20"/>
<RichTextBox>
<RichTextBox.LayoutTransform>
<ScaleTransform ScaleX="{Binding ElementName=Scale, Path=Value}" ScaleY="{Binding ElementName=Scale, Path=Value}"/>
</RichTextBox.LayoutTransform>
</RichTextBox>
</DockPanel>
</P
这篇关于是否有可能"变焦"在WPF RichTextBox的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!