【问题标题】:WPF Document Viewer End of DocumentWPF 文档查看器文档结尾
【发布时间】:2018-07-03 16:35:22
【问题描述】:

当 DocumentViewer 到达 XPS 文档的末尾时,如何更新用户控件各自 ViewModel 中的属性?

要查看文档,我将 XPS 文档下载到应用程序并使用 IDocumentPaginatorSource 属性绑定到 DocumentViewer 中的 Document 属性。文档(转换后的 PowerPoint 演示文稿)加载得很好,用户可以滚动 PPT,就好像它是一个单页文档一样。很好。

我知道在使用独立 Scrollviewer 时如何识别文档结束事件,但我在 DocumentViewer 本身或其 Scrollviewer 中找不到任何功能。

以下是相关代码。请善意并告知是否有更好的方法来提出这个问题,或者我是否错过了一个基本概念,我很乐意编辑。谢谢!

查看

<DocumentViewer Grid.Row="0"
                Name="DocumentViewPowerPoint"
                VerticalAlignment="Top"
                HorizontalAlignment="Left"
                Document="{Binding FixedFixedDocumentSequence}"
                ScrollViewer.ScrollChanged="OnScrollChanged"
                SizeChanged="DocumentViewPowerPoint_SizeChanged"
                Loaded="DocumentViewPowerPoint_Loaded"
                Visibility="{Binding XPSVis}"
                />

查看背后的代码

public TRCourseView(TrainingCourses selectedcourse, InterfaceDialogService dialogservice)
{
       InitializeComponent();

      _viewModel = new TRCourseViewVM(selectedcourse, dialogservice);
       this.DataContext = _viewModel;
}

private void OnScrollChanged(object sender, ScrollChangedEventArgs e)
{
    if (DocumentViewPowerPoint.CanMoveDown == false)
        MessageBox.Show("This Is The End");
}

视图模型

private IDocumentPaginatorSource _fixedDocumentSequence;
public IDocumentPaginatorSource FixedFixedDocumentSequence
{
      get { return _fixedDocumentSequence; }
      set { SetProperty(ref _fixedDocumentSequence, value, () => FixedFixedDocumentSequence); }
}

【问题讨论】:

  • 你可以使用 MasterPageNumber 或 PageCount 如此处所示social.msdn.microsoft.com/Forums/vstudio/en-US/…
  • 非常感谢麻木舌!这为我指明了正确的方向并提供了更好的解决方案。我在 DocumentViewer 中使用了 PageViewsChanged 事件,并将 if 语句“if (DocumentViewPowerPoint.PageCount == DocumentViewPowerPoint.MasterPageNumber)”放入事件中。我如何评价您回答问题?
  • 太棒了!你已经有了,除了你自己解决了..

标签: c# wpf


【解决方案1】:

我在 DocumentViewer 中使用了 PageViewsChanged 事件,并将 if 语句“if (DocumentViewPowerPoint.PageCount == DocumentViewPowerPoint.MasterPageNumber)”放入事件中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-08
    • 2022-01-05
    相关资源
    最近更新 更多