dotnet / dotnet/wpf

ContextMenu/MenuItem, Dpi in PerMonitorV2 mode, scaling error in WPF with programmatic opening

Open
#3,874 12 comments 1 reaction 0 assignees View on GitHub
:construction: work in progress Bug
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

Hello,
Using dpi sensitivity in PerMonitorV2 mode, I noticed an issue scaling the 1st MenuItem list of a ContextMenu when switching from a 100% scale monitor to a 2nd 150% scale monitor.
This error occurs in my test program when I open the contextMenu using the left button in the test button click event.
With the right mouse button, the scaling is correct.
The contextMenu is a child of the button in the XML code.

I have found:
1. There is no scaling of the 1st MenuItem list.
2. The MenuItems contained in a MenuItem from the 1st list are correctly scaled.

Framework 4.8 and net .5 give the same error.
If I don't use dpi sensitivity in PerMonitorV2 mode, scaling works fine.

I am attaching a zip file with a test program with which you can test and verify the problem.
[WpfPopupNet5.zip](https://github.com/dotnet/wpf/files/5624695/WpfPopupNet5.zip)

![PopupPerMonitorV2](https://user-images.githubusercontent.com/66659162/100782908-604fe500-340d-11eb-9b66-e1875b5af98b.gif)

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.