How do I send a NavigationCommand to a control?

1.5k Views Asked by At

FlowDocumentReader doesn't have a GoToPage method, but it supports NavigationCommands.GoToPage RoutedUICommand.

How do I send NavigationCommands.GoToPage with parameter (for example: 1) to my FlowDocumentReader from within my code (not using xaml)?

Thanks, Yariv

Edited: Thanks! But though I can send the command with your help, I don't get the expected results. This is the code (and I tried to use FirstPage instead of PreviousPage too):

if (NavigationCommands.PreviousPage.CanExecute(null, this) == true)
{
    NavigationCommands.PreviousPage.Execute(null, this);
}

Even though the if statement is true and the inner code is being executed, the FlowDocumentReader stays in the last page...

1

There are 1 best solutions below

1
On
FlowDocumentReader flowDoc;
...
NavigationCommands.GoToPage.Execute("my parameter", flowDoc);