user2654308
user2654308

Reputation: 21

WPF Document Viewer End of Document

How does one update a property in a User Control's respective ViewModel when the DocumentViewer reaches the end of an XPS Document?

To view the document, I download the XPS Document to the app and use an IDocumentPaginatorSource property to bind to the Document property in the DocumentViewer. The document (a converted PowerPoint presentation) loads just fine and the user is able to scroll through PPT as if it was a one page document. Fine.

I know how to identify the end of document event when using a standalone Scrollviewer, but I can't find any function in the DocumentViewer itself or its Scrollviewer.

Following is relevant code. Please be kind and advise if there is a way to better ask this question or if I have missed a basic concept and I will gladly edit. Thank you!

View

<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}"
                />

View Code Behind

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");
}

ViewModel

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

Upvotes: 1

Views: 297

Answers (1)

user2654308
user2654308

Reputation: 21

I used the PageViewsChanged event in the DocumentViewer and put the if statement "if (DocumentViewPowerPoint.PageCount == DocumentViewPowerPoint.MasterPageNumber)" in the event.

Upvotes: 1

Related Questions