WPF 工具栏中 OverFlowButton 的颜色
有问题。当我更改 WPF 工具栏的背景颜色时,右上角的溢出按钮不会改变颜色。如何修复它?
There was a problem. When I change the background color of WPF toolbar Overflow Button in the right corner does not change color. How to fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不幸的是,溢出按钮有固定的背景。更准确地说,它在默认模板中设置为静态值。请参阅此 MSDN 论坛主题 或 MSDN(如果您想获取他们。或者 Chris Sells 提供的这个工具
在模板中,您会看到一个 ToggleButton,它用于显示/隐藏溢出面板。需要更改这一点才能达到您想要的效果。
因此,您的问题的答案是您需要在 XAML 中包含工具栏的完整样式,并将按钮的背景更改为与工具栏的其余部分相同。
The overflow button unfortunately has a fixed background. More precisely, it is set to a static value in the default template. See this MSDN forum thread or MSDN if you want to get a copy of them. Or This tool from Chris Sells
In the template, you'll see a ToggleButton, that is used to show/hide the overflow panel. This is the one to change to have the effect that you are looking for.
So, the answer to your question is that you need to include the full style of the toolbar in your XAML and change the background of the button to be the same as the rest of the toolbar.
我遇到了你上面描述的同样的问题。我的解决方案如下:
XAML 示例:
I had the same problem you described above. My solution is the following:
XAML sample:
亚历克斯的回答很好。修改OverflowButton和OverflowPanel颜色的另一种方法是在loaded事件中修改它们。
XAML
代码隐藏:
名称(OverflowGrid、OverflowButton 和 PART_ToolBarOverflowPanel)可以在默认控件模板中找到,该模板可以从 WPF 的 GitHub 页面下载。
Alex's answer is good. Another way to modify the color of the OverflowButton and OverflowPanel is to modify them in the loaded event.
XAML
Code behind:
The names (OverflowGrid, OverflowButton, and PART_ToolBarOverflowPanel) can be found in the default control template, which could be downloaded from WPF's GitHub page.
Alex Padabed 的答案很接近,但根据 OP 错过了下拉按钮。您可以通过添加以下内容来解决此问题:
Alex Padabed's answer was close, but missed the dropdown button as per the OP. You can remedy this by adding: