CommunityToolkit / Microsoft.Toolkit.Win32

ARCHIVE - This repository contained XAML Islands wrapper controls and tooling for XAML Islands with WinUI 2, see readme for more info about XAML Islands with WinUI 3 and the WindowsAppSDK.
https://aka.ms/windowsappsdk
Other
384 stars 89 forks source link

It's not possible to print through Xamlslands in WPF #307

Open atiyka opened 3 years ago

atiyka commented 3 years ago

Describe the bug

In a WPF application (targeting .NET core 3.1) I'm using XamlHosts to display windows 10 design UI elements. I'd like to print from my app - display the Win10 print preview.

I checked the printing in UWP Samples, I could start and it's working. But as I moved the code to my custom UWP component (which is displayed in the WPF application), the print preview doesn't display. As I call the await PrintManager.ShowPrintUIAsync();, it throws the following exception:

Error: System.ArgumentException: Value does not fall within the expected range.

None of the following callbacks are fired: Paginate, GetPreviewPage, AddPages, PrintTaskRequested. So, the error happens before any of these are called.

I checked every setting and configuration in the sample app (where it's working) and everything is the same as in my app. So, I'm wondering if the problem is with the XamlIslands?

Steps to Reproduce

I created a sample project, where it reproduces the issue. You can find it here. The exception raises in PrintHelper.cs:116.

Expected behavior

It would be great if I could show to the user the win10 designed print preview UI.

Environment

NuGet Package(s): 
Microsoft.Toolkit.Wpf.UI.XamlHost - version 6.1.2

Project .NET Version:
- [x] .NET Core 3.1

Windows 10 Build Number:
- [x] version 2004, os build 9041.746

App min and target version:
- [x] May 2019 Update (18362)

Device form factor:
- [x] Desktop

Visual Studio 
- [x] 2019 Community (version: 16.7.7)
ghost commented 3 years ago

Hello atiyka, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback šŸ™Œ

ghost commented 3 years ago

This issue has been marked as "needs attention šŸ‘‹" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost commented 3 years ago

This issue has been marked as "needs attention šŸ‘‹" due to no activity for 15 days. Please triage the issue so the fix can be established.

michael-hawker commented 3 years ago

FYI @marb2000