简体   繁体   English

WPF ContextMenu出现在鼠标的左侧

[英]WPF ContextMenu apprears on left side of the mouse

Whenever I'm creating a ContextMenu it appears on the left side of the mouse instead of the usual right side for some reason. 每当我创建ContextMenu时,由于某种原因,它都会出现在鼠标的左侧,而不是通常的右侧。 I'm not tweaking any settings in the ContextMenu object, all I'm doing is instantiating it, adding item(s) and setting IsOpen to true. 我没有调整ContextMenu对象中的任何设置,我要做的只是实例化它,添加项目并将IsOpen设置为true。 I'm using MahApps.Metro, and the window also has a custom WindowChrome, but I don't this it has anything to do with this weird behavior. 我正在使用MahApps.Metro,并且该窗口还具有自定义的WindowChrome,但我不认为这与这种怪异的行为有关。 This had never happened to me before, and I hope that somebody can explain why this might be happening and how to I fix it. 我以前从未发生过这种情况,我希望有人可以解释为什么会发生这种情况以及如何解决。

This is my code: 这是我的代码:

ContextMenu = new ContextMenu();

MenuItem item = new MenuItem();
item.Header = "Add Category";
item.Click += (o, args) =>
{
    ...
};
ContextMenu.Items.Add(item);
ContextMenu.IsOpen = true;

PS This is not caused because there is not enough room for the menu, I've tested it on the far left side of the screen. PS这不是由于菜单空间不足而引起的,我已经在屏幕的最左侧对其进行了测试。

I finally found the solution. 我终于找到了解决方案。 All I had to do is change the Windows 10 Tablet PC Settings from Right-Handed to Left-Handed. 我要做的就是将Windows 10 Tablet PC设置从右手更改为左手。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM