2014-09-11 88 views
0

我有一個的DocumentViewer它,我的文檔屬性設置爲XPS文件WPF的DocumentViewer - 滾動到頁/位置

var x = new XpsDocument(tempFile, FileAccess.Read); 
      Document = x.GetFixedDocumentSequence(); 
x.Close(); 

設定了文檔我如何可以滾動到頁面x或到位置y像素放下文件?

編輯:

我現在已經修改爲:

var x = new XpsDocument(tempFile, FileAccess.Read); 
Document = x.GetFixedDocumentSequence(); 
VerticalOffset = 250; 
x.Close(); 

現在看來,每個其他時間一次正常滾動,但兩者之間似乎總是回到開始滾動。這很奇怪,我無法解釋它。有任何想法嗎?

回答

0

我不知道這是否適用於您的特定問題,但每當我需要滾動到XPS文檔中的特定點時,我必須將VerticalOffset放在DocumentViewer的Loaded事件中,否則它會嘗試在任何事物實際存在之前滾動。

編輯:

我想我已經重新創建你的問題,你居然要放置VerticalOffset中的DocumentViewer的LayoutUpdated事件,它應該每次加載新文檔時,希望觸發。