PdfViewerControl.PrintDocumentCommand Property
In This Article
Prints the document.
Namespace: DevExpress.UI.Xaml.Controls
Assembly: DevExpress.UI.Xaml.Controls.v21.2.dll
NuGet Package: DevExpress.Uwp.Controls
#Declaration
#Property Value
Type | Description |
---|---|
ICommand | A command that implements the Windows. |
#Remarks
To learn more about using commands, refer to MSDN.
The example below illustrates a view model that implements the PrintDocumentCommand.
public class MainViewModel : ViewModelBase {
public ICommand PrintDocumentCommand { get; private set; }
public IPrintDocumentSource PrintDocumentSource { get; set; }
CoreDispatcher dispatcher = Window.Current.Dispatcher;
public MainViewModel() {
if (ViewModelBase.IsInDesignMode)
return;
PrintDocumentCommand = new DevExpress.Mvvm.DelegateCommand(PrintDocument);
}
async void PrintDocument() {
PrintManager.GetForCurrentView().PrintTaskRequested += printManager_PrintTaskRequested;
await PrintManager.ShowPrintUIAsync();
PrintManager.GetForCurrentView().PrintTaskRequested -= printManager_PrintTaskRequested;
}
void printManager_PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs args) {
PrintTask printTask = null;
printTask = args.Request.CreatePrintTask("PdfViewer Demo Print Task", sourceRequested => {
printTask.Completed += async (s, e) => {
if (e.Completion == PrintTaskCompletion.Failed) {
await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () => {
await new MessageDialog("Printing error.").ShowAsync();
});
}
};
sourceRequested.SetSource(PrintDocumentSource);
});
}
}
See Also