本文介绍了WPF RichTextBox的滚动到TextPointer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在WPF RichtTextBox有滚动的方法:
The WPF RichtTextBox has a method to scroll:
RichTextBox.ScrollToVerticalOffset(double)
我想以这样的方式滚动,即一个cerctain范围或至少它开始进入视野。我如何转换的TextPointer以一种有意义的方式增加一倍?
I want to scroll in such a way, that a cerctain range or at least the start of it comes into view. How can I convert a TextPointer to double in a meaningful way?
推荐答案
有一个看FrameworkElement.BringIntoView方法。我使用的是这样的:
Have a look at the FrameworkElement.BringIntoView Method. I'm using something like this:
public void Foo(FlowDocumentScrollViewer viewer) {
TextPointer t = viewer.Selection.Start;
FrameworkContentElement e = t.Parent as FrameworkContentElement;
if (e != null)
e.BringIntoView();
}
这篇关于WPF RichTextBox的滚动到TextPointer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!