在清除并重新加载wpf richtextbox中的内容后,清除pageup/pagedown平移值吗? [英] Clear pageup/pagedown panning values after clear and reload content in wpf richtextbox?

查看:244
本文介绍了在清除并重新加载wpf richtextbox中的内容后,清除pageup/pagedown平移值吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在wpf richtextbox中工作.请使用以下功能将页面向上翻页.

i am working in wpf richtextbox.use the below function use for page up.

TextRange range10 = new TextRange(txtAppendValue.CaretPosition.GetLineStartPosition(1), txtptrCaret);

                FrameworkContentElement fce1 = (range10.End.Parent as FrameworkContentElement);
                if (fce1 != null)
                {
                    fce1.BringIntoView();
                    range10 = null;
                    fce1 = null;
                }

它可以正常工作.在我清除richtextbox并加载了其他内容之后,当时的内容显示了上次分页的位置?如何在重新加载文档时清除.

its working.After i clear the richtextbox and load some other content,at that time the content shown where the pageup happened in last time?how to clear when i reload the document.

已更新:

public void HideTopBorder()
        {
            TextPointer currentline = txtAppendValue.CaretPosition.GetLineStartPosition(1);
            System.Windows.Rect rc = currentline.GetCharacterRect(LogicalDirection.Forward);
            System.Windows.Point upperLeftCorner = rc.Location;
            HitTestResult result = VisualTreeHelper.HitTest(txtAppendValue, upperLeftCorner);
            if (result == null)
            {

                Thickness margin = txtAppendValue.Margin;
                margin.Top = -20;
                txtAppendValue.Margin = margin;
                currentline = null;
            }
            else
            {
                currentline = null;
            }

        }

结果为null后,仅发生了pageup.那时候,我清除了文档并加载了另一个文档.但是现在显示richtextbox在已经平移的位置,而不是文档的顶部.

After the result null only pageup happened.at that time i clear the document and load an another document.But now show the richtextbox where the already panned point.not top of the document.

问候 阿琼

推荐答案

在加载新文档之前,请保存rtb.VerticalOffset的值.然后加载新文档,并将存储的值重新分配给rtb.VerticalOffset.

Before you load a new document save the value of rtb.VerticalOffset. Then load the new document and reassign the stored value to rtb.VerticalOffset.

这篇关于在清除并重新加载wpf richtextbox中的内容后,清除pageup/pagedown平移值吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆