PrintManager.PrintTaskRequested Event
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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.
// Register
event_token PrintTaskRequested(TypedEventHandler<PrintManager, PrintTaskRequestedEventArgs const&> const& handler) const;
// Revoke with event_token
void PrintTaskRequested(event_token const* cookie) const;
// Revoke with event_revoker
PrintManager::PrintTaskRequested_revoker PrintTaskRequested(auto_revoke_t, TypedEventHandler<PrintManager, PrintTaskRequestedEventArgs const&> const& handler) const;
public event TypedEventHandler<PrintManager,PrintTaskRequestedEventArgs> PrintTaskRequested;
function onPrintTaskRequested(eventArgs) { /* Your code */ }
printManager.addEventListener("printtaskrequested", onPrintTaskRequested);
printManager.removeEventListener("printtaskrequested", onPrintTaskRequested);
- or -
printManager.onprinttaskrequested = onPrintTaskRequested;
Public Custom Event PrintTaskRequested As TypedEventHandler(Of PrintManager, PrintTaskRequestedEventArgs)
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:
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.
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 |