PrintManager.PrintTaskRequested Event

Definition

Raised when a request to print has occurred. This event may be triggered by user action or via programmatic invocation of printing via the ShowPrintUIAsync method.

C#
public event TypedEventHandler<PrintManager,PrintTaskRequestedEventArgs> PrintTaskRequested;

Event Type

Remarks

When you add print capabilities to your UWP app, you have to implement an event handler to process this event when it is raised. Here is a code snippet from the UWP print sample that shows how to handle this event:

C#
protected virtual void PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs e)
{
    PrintTask printTask = null;
    printTask = e.Request.CreatePrintTask("C# Printing SDK Sample", sourceRequested =>
    {
        // Print Task event handler is invoked when the print job is completed.
        printTask.Completed += async (s, args) =>
        {
            // Notify the user when the print operation fails.
            if (args.Completion == PrintTaskCompletion.Failed)
            {
                await scenarioPage.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    MainPage.Current.NotifyUser("Failed to print.", NotifyType.ErrorMessage);
                });
            }
        };

        sourceRequested.SetSource(printDocumentSource);
    });
}

To see the complete listing for this and other printing scenarios using PrintTaskRequested, see Printing and the UWP print sample.

Applies to

Product Versions
WinRT Build 10240, Build 10586, Build 14383, Build 15063, Build 16299, Build 17134, Build 17763, Build 18362, Build 19041, Build 20348, Build 22000, Build 22621, Build 26100

See also