Oxyplot is not printed (blank) when Printing WPF UI which is rescaled to fit on one page using .NET 7
Steps to reproduce
- Clone the repo from : https://github.com/supershopping/OxyPlotPrintTest
- Run application
- Click "Add Data" button
- Click "Print" button and select a printer to print on a "letter size paper".
Platform: .NET version: .NET 7
Expected behaviour
My goal is to print the WPF UI Window "Main" or the Datagrid "ReportGrid". The printing code is just to transform/resacle the UI to fit on one "letter" page. The Oxyplot is supposed to resize and print.
Actual behaviour
Once the UI is printed, you can see the buttons on the right side of the UI are prined but the Oxyplot is blank and not printed. I have another application using .NET framework 4.8 instead of .NET 7. With the same printing code, the UI printing is working properly. It seems an compatability issue with Oxyplot library using .NET 7, and I am not sure how to fix this or is there a workaround?
I did a lot of testing. It turns out the pringting issue is related to Oxyplot version 2.1.2. When I am using 2.0 version of the library, the printing is working fine. Version 2.0 works for both .NET framework 4.8 and .NET7. Sorry for the confusion from my original post.
To clarify, it works with 2.0.0 with netframework4.8 and net7.0, but not with 2.1.2 on net7.0?
Are you able to provide any sort of reproducing example?
Yes. The Oxyplot 2.0.0 works with netframework4.8 and net7.0, The Oxyplot 2.1.2 does not work with netframework4.8 and net7.0, I have created an example (using .NET 7) at this repo: https://github.com/supershopping/OxyPlotPrintTest
The "Master" branch is using Oxyplot 2.0 version. Printing UI is OK. [UsingVersion2.1.2] branch is using Oxyplot 2.1.2. Printing UI is not working.
You can put a breakpoint on "pd.PrintVisual(v, "My Print");" and check the "v" through WPF Visualizer. The oxplot is empty in the Visualizer. The same result when you are printing on a real letter size paper.