Windows Dev Center

PrintManager.ShowPrintUIAsync | showPrintUIAsync method

Programmatically initiates the user interface for printing content.

Syntax


public:
static IAsyncOperation<bool>^ ShowPrintUIAsync()

Parameters

This method has no parameters.

Return value

Type: IAsyncOperation<Boolean>

A Boolean value to indicate a TRUE for success or a FALSE for a failure.

Remarks

ShowPrintUIAsync is an asynchronous method that displays the appropriate printing window. If printing can't be performed at that time, the method will throw an exception. We recommend catching these exceptions and letting the user know when printing can't proceed, as shown here.


async private void printButton_Click(object sender, RoutedEventArgs e)
{
    try
    {
        // Show print UI
        await Windows.Graphics.Printing.PrintManager.ShowPrintUIAsync();

    }
    catch
    {
        // Printing cannot proceed at this time
        ContentDialog noPrintingDialog = new ContentDialog()
        {
            Title = "Printing error",
            Content = "\nSorry, printing can't proceed at this time.", PrimaryButtonText = "OK"
        };
        await noPrintingDialog.ShowAsync();
    }
}

In this example, a print window is displayed in the event handler for a button click. If the method throws an exception (because printing can't be performed at that time), a ContentDialog control informs the user of the situation. For more info about printing from your app, see Printing.

Requirements (Windows 10 device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.Graphics.Printing
Windows::Graphics::Printing [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

None supported

Namespace

Windows.Graphics.Printing
Windows::Graphics::Printing [C++]

Metadata

Windows.winmd

See also

Printing
PrintManager

 

 

Show:
© 2015 Microsoft