方法 : PrintDialog を作成および表示する

更新 : 2007 年 11 月

この例では、PrintDialog を表示する方法を示します。

使用例

次の例は、印刷ダイアログを表示する方法を示しています。

<Button Width="200" Click="InvokePrint">Invoke PrintDialog</Button>

...

private void InvokePrint(object sender, RoutedEventArgs e)
    {
        // Create the print dialog object and set options
        PrintDialog pDialog = new PrintDialog();
        pDialog.PageRangeSelection = PageRangeSelection.AllPages;
        pDialog.UserPageRangeEnabled = true;

        // Display the dialog. This returns true if the user presses the Print button.
        Nullable<Boolean> print = pDialog.ShowDialog();
        if (print == true)
        {
            XpsDocument xpsDocument = new XpsDocument("C:\\FixedDocumentSequence.xps", FileAccess.ReadWrite);
            FixedDocumentSequence fixedDocSeq = xpsDocument.GetFixedDocumentSequence();
            pDialog.PrintDocument(fixedDocSeq.DocumentPaginator, "Test print job");
        }
    }

サンプル全体については、「PrintDialog のサンプル」を参照してください。

参照

参照

PrintDialog