Skip to main content
All docs
V23.2

Commands in Document Viewer for WinUI

The DocumentViewer.Commands collection contains the Document Viewer commands and allows the user to obtain a command and bind the command to a UI element. All commands implement the ICommand interface. To execute a command, call the command’s Execute method.

The following code invokes the Open dialog when the Document Viewer is loaded:

private void DocumentViewer_Loaded(object sender, RoutedEventArgs e) {
    documentViewer.Commands.ShowOpenDialogCommand.Execute(null);
}

A command’s CanExecute method determines whether the command can be executed.

The following help topic describes how to use commands to create a custom Document Viewer toolbar: Customize the Document Viewer Toolbar in the WinUI Application