dotnet / dotnet/winforms

Support for the Win11 22H2 UnifiedPrintDialog

Open
#13,264 4 comments 1 reaction 1 assignee Claimed by @KlausLoeffelmann View on GitHub
api-suggestion Regression by Win-OS
Dominant language
C#
Stars
4.9k
Forks
1.1k
Avg merge
20h 23m
Merged PRs (30d)
103

Description

### .NET version

.NET8

### Did it work in .NET Framework?

Not tested/verified

### Did it work in any of the earlier releases of .NET Core or .NET 5+?

_No response_

### Issue description

Windows 11 22H2 introduced a new UnifiedPrintDialog that is shown when the System.Windows.Forms.PrintDialog is used.

![Image](https://github.com/user-attachments/assets/8951c187-0008-444f-8bc1-d69e7d50e68e)

I see two problems in this situation:

**Problem 1:**
I can set Landscape/portrait orientation by setting `printDialog.PrinterSettings.DefaultPageSettings.Landscape = true`. But this is ignored by the new dialog. After clicking "OK", the predefined orientation thus is lost, only the setting in the dialog is applied.

**Problem 2:**
There is no way to populate the page preview box to the right. This is actually an unnecessary feature for me, as it happens for me when using a commercial reporting tool which provides a page preview control. In this control, the "print" button just shows the printer selection dialog, and page setup (e.g. orientation) is done in other controls).

The easiest way to resolve this is probably to set the registry key "Computer\HKEY_CURRENT_USER\Software\Microsoft\Print\UnifiedPrintDialog\PreferLegacyPrintDialog" = 1 (see e.g. https://www.vbforums.com/showthread.php?901260-The-modern-print-dialog-issue-after-Windows-11-22H2-update).
This brings back the old dialog.

Would it be possible to add a property to "PrintDialog" similar to "UseEXDialog" which enables/disables the Win11 form? This would resolve the issue for me, as I cannot populate the page preview in my app.

I assume this issue is already known, but I did not find anything in this repository.

Similar issue for WPF: https://www.github.com/dotnet/wpf/issues/8355

### Steps to reproduce

Attached is a small sample:
[WinFormsPrintDialog.zip](https://github.com/user-attachments/files/19644250/WinFormsPrintDialog.zip)

You can set landscape/portrait with two radio buttons, then click the "Print Dialog" button => now the new dialog should be shown which is always set to "landscape".

If you set the registry key "Computer\HKEY_CURRENT_USER\Software\Microsoft\Print\UnifiedPrintDialog\PreferLegacyPrintDialog" = 1 and perform the same steps, you should see that the landscape setting is applied to the printer settings. So, it worked in the old version of the form.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.