Share via


PrintTaskSourceRequestedArgs 類別

定義

PrintTaskSourceRequestedHandler 委派相關聯的引數。 提供將內容列印至 PrintTask 的方法。

public ref class PrintTaskSourceRequestedArgs sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class PrintTaskSourceRequestedArgs final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class PrintTaskSourceRequestedArgs
Public NotInheritable Class PrintTaskSourceRequestedArgs
繼承
Object Platform::Object IInspectable PrintTaskSourceRequestedArgs
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

備註

PrintTaskSourceRequestedArgs 可用來設定要列印的內容來源。 以下是 UWP 列印範例 的程式碼片段,其中顯示 SetSource 方法:

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);
                });
            }
        };

        // Call PrintTaskSourceRequestedArgs.SetSource
        sourceRequested.SetSource(printDocumentSource);
    });
}

如需此和其他列印案例的詳細資訊,請參閱 列印UWP 列印範例

屬性

Deadline

取得 DateTime 物件,這個物件表示列印工作來源要求的期限。

方法

GetDeferral()

取得 PrintTaskSourceRequestedDeferral 物件,該物件提供 Complete 方法的存取權。 這個方法表示延遲已結束。

SetSource(IPrintDocumentSource)

通知列印工作要列印的內容。

適用於