查找DocumentViewer的ScrollViewer的最大偏移量

编程入门 行业动态 更新时间:2024-10-19 18:24:48
本文介绍了查找DocumentViewer的ScrollViewer的最大偏移量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在DocumentViewer中显示一个xps文档. 在程序中,DocumentViewer旁边有一个树状视图列表,当您选择每个项目时,它应将xps文件导航到特定位置(就像pdf书签一样). 问题是我必须将VerticalScrollbar位置设置为特殊位置,并使其即使通过页面缩放等也唯一且稳定. 为此,我尝试通过比率(偏移=比率* maxoffset)设置位置,但是找不到maxoffset,实际上"ScrollViewer.Content.ActualHeight"与滚动条末尾的偏移不同. 我的代码是:

Hi, I am showing a xps document in a DocumentViewer. In the program there is a treeview list next to the DocumentViewer that when you select each item it should navigate the xps file to specifice place(just like pdf bookmark). The problem is i have to set the VerticalScrollbar position to a special position and make it unique and stable even by page zoom and etc. for that i tried to set the position by the ratio (offset = ratio * maxoffset) but cant find the maxoffset, actually the "ScrollViewer.Content.ActualHeight" is different from the offset at the end of the scrollbar. my code is:

ScrollViewer dvScrollViewer = documentViewer.Template.FindName("PART_ContentHost", documentViewer) as ScrollViewer; dvScrollViewer.ScrollToEnd(); MessageBox.Show(dvScrollViewer.VerticalOffset.ToString()); MessageBox.Show((dvScrollViewer.Content as FrameworkElement).ActualHeight.ToString());

但是第一个消息是86667.307 第二个是573.696 有帮助吗? 很长的问题和英语对不起,:D

But the firs message is 86667.307 and the second one : 573.696 any Help? sorry for the long question and the english :D thanks.

推荐答案

嗨. 请尝试以下操作: dvScrollViewer.ScrollToEnd(); dvScrollViewer.UpdateLayout(); MessageBox.Show(dvScrollViewer.VerticalOffset.ToString()); MessageBox.Show((dvScrollViewer.Content as FrameworkElement).ActualHeight.ToString()); 问候. Hi. Please try this: dvScrollViewer.ScrollToEnd(); dvScrollViewer.UpdateLayout(); MessageBox.Show(dvScrollViewer.VerticalOffset.ToString()); MessageBox.Show((dvScrollViewer.Content as FrameworkElement).ActualHeight.ToString()); Regards.

更多推荐

查找DocumentViewer的ScrollViewer的最大偏移量

本文发布于:2023-11-12 04:06:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580473.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:偏移量   DocumentViewer   ScrollViewer

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!