WPF DPI Scaling with DPIScaling Demo Code

Add-in Express™ Support Service
That's what is more important than anything else

WPF DPI Scaling with DPIScaling Demo Code
 
Sean Devenish




Posts: 78
Joined: 2015-11-30
I understand this might not be specifically related to Add-in Express, so let me know if I should ask elsewhere for this issue. I've spent so long exploring what might be causing this, and haven't been able to find anything.

I'm working with a .NET Framework 4.6.2 project, hooking into Outlook via Add-in Express 9.5.4661. All Add-in Express functions are working as expected, and the add-in successfully registers with Outlook. I've also successfully based DPI scaling support off the research and examples given by Andrei here: https://www.add-in-express.com/creating-addins-blog/2021/06/17/dpi-scaling-details-office-addins/

Graphically, the dialog scales perfectly. All elements retain their layout and reach the correct size. What doesn't work is the elements along the right and bottom edge of the window can no longer be interacted with. Moving the mouse across them triggers hover events, but they flicker, and cannot be clicked. This area appears to be the difference between the non-scaled and the scaled window size.

Simply taking the code from my control and placing it in UserControl2.xaml of DpiScaling shows the problem doesn't occur there. But taking the UserControl2.xaml code and placing it in my control, and adding in elements to the right side, it occurs again.

Do you have any ideas what might be causing this? Did you come across such behaviour when putting together the DpiScaling demo?
Posted 25 Aug, 2021 00:53:04 Top
Andrei Smolin


Add-in Express team


Posts: 17962
Joined: 2006-05-11
Hello Sean,

No, I can't remember ever seeing this behavior. Could you send me some code for testing to our support email address?

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 25 Aug, 2021 02:10:27 Top
Sean Devenish




Posts: 78
Joined: 2015-11-30
Thanks for getting back to me Andrei.

This has been such a weird issue that I tried to get some demo code together, and no matter what I extracted, the code itself wouldn't present the issue. The entire project is a bit too much to be able to send through though, so I'll have to explore some other avenues.

Thanks for confirming you weren't faced with similar symptoms in your research.
Posted 30 Aug, 2021 23:19:08 Top
Andrei Smolin


Add-in Express team


Posts: 17962
Joined: 2006-05-11
Hello Sean,

Next week I'll be able to get a specialist look into your issue. When this happens, I'll drop you a note.

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 31 Aug, 2021 05:52:04 Top
Andrei Smolin


Add-in Express team


Posts: 17962
Joined: 2006-05-11
Hello Sean,

Since you don't reproduce the issue when you create a sample project, you can try to comment out blocks of your code to find what causes the issue.

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 06 Sep, 2021 07:53:02 Top
Yevhen Lysakov




Posts: 10
Joined: 2021-06-02
We've faced exactly the same issue with our WPF buttons in our Outlook addin. When Outlook window is opened on monitor with >100% scaling, buttons on the right side of the panel flickers when you move mouse over them, and it's almost impossible to click on them. While buttons on the left part of the panel works just fine.
Spend full day trying to find the difference between our addin and simple sample Outlook addin from Addin Express team and finally found the root cause.
In event handler for AddinModule_AddinInitialize event, we had following line:
CurrentDispatcher = System.Windows.Threading.Dispatcher.CurrentDispatcher;

in order to save current Dispatcher for later use.
so if this line is added to sample addin - issue can be reproduced there easily.

My plan is to remove this line completely, and use "OnSendMessage" events to achieve required functionality.

Hoping this would help others stumbling on same issue.
Posted 04 Oct, 2021 10:34:43 Top
Andrei Smolin


Add-in Express team


Posts: 17962
Joined: 2006-05-11
Hello Yevhen,

That's a great find! Thank you for sharing it with the forum readers! Thank you a lot.

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 04 Oct, 2021 11:14:59 Top
Sean Devenish




Posts: 78
Joined: 2015-11-30
That's great Yevhen, thanks for the heads up!

I can see we are indeed doing the same thing during initialisation. I'll be sure to investigate further into how we can work around this use of the dispatcher and hopefully get DPI scaling working correctly.

Really appreciate the help.
Posted 04 Oct, 2021 18:16:38 Top