更改上下文菜单的宽度会导致渲染效果不佳

发布于 2024-07-29 07:16:58 字数 421 浏览 1 评论 0原文

我想做的就是在 Button 上有一个 ContextMenu,其宽度限制为 Button 的宽度。 显然这太过分了。 如果您打开ContextMenu,然后减小Button 的大小并再次打开它,则一切正常(Width 变小)。 如果增加 Width(例如,从 100 到 200),ContextMenuWidth 也会增加(到 200),但它只会呈现前一个宽度 (100)。 我自己在代码中更改了 Width ,并使用 ActualWidth 代替,但尽管这些值看起来不错,但上下文菜单的渲染很差。

All I wanted to do is have a ContextMenu on a Button with the width bounded to the Button's width. Apparently that's too much. If you open the ContextMenu and then decrease the size of the Button and open it again everything's OK (the Width gets smaller). If you increase the Width (from 100 to 200 for example) the ContextMenu's Width increases too (to 200) but it only renders the previous Width (100). I changed the Width myself in code, used ActualWidth instead but though the values seem fine, the context menu's rendering is poor.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

泛滥成性 2024-08-05 07:16:58

上下文菜单的宽度似乎是由具有最长文本字段的上下文项的文本字段长度驱动的。

如果将一堆空格附加到上下文项的文本字段之一,这会使该上下文项和整个上下文菜单变得更宽。

然后一切都画得很好。

希望这可以帮助。

The width of the context menu seems to be driven by the text field length of the context item with the longest text field.

If you append a bunch of spaces to one of the context item's text field this makes both that context item and the whole context menu wider.

Everything then draws fine.

Hope this helps.

温暖的光 2024-08-05 07:16:58

不确定这是否适用,但您可以选择使用 SnapToDevicePixels=True 吗? 我发现这在不使用时会对渲染产生巨大的影响...但我不确定该选项是否在您的上下文菜单上可用。

Not sure if this applies, but do you have the option to use the SnapToDevicePixels=True? I have found this makes a massive difference in rendering when it is not used... but I am not sure if the option is available on your context menu.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文