选中在菜单中显示为黑框的标记 [英] Check Mark Showing as a Black Box in Menu

查看:29
本文介绍了选中在菜单中显示为黑框的标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在工具栏中有一个需要检查的菜单,但是当我检查项目时,它呈现为一个黑框(我尝试上传问题的照片,但 StackOverflow 不允许我上传).当您将鼠标悬停在复选标记上时,会正确呈现.我不明白我已经尝试删除任何可能影响它的样式,但似乎没有任何影响.

I have a menu inside a toolbar that needs to be checkable but when I check the items it renders as just a black box (I tried to upload a photo of the issue but StackOverflow wouldn't let me). When you mouse over the check mark renders correctly. I don't understand it I have tried removing any styles that might be affecting it but nothing seems to affect it.

有人可以帮忙吗?

这是菜单项的 XAML:

Here is the XAML for the menu item:

<ToolBar ToolBarTray.IsLocked="True" Margin="0" Padding="0" ToolBar.OverflowMode="Never">
    <Button Command="com:FormatCommands.LogInCommand">
        <Viewbox Width="15">
            <Image Source="..ResourcesLogin.png"/>
        </Viewbox>                        
    </Button>
    <Button Command="com:FormatCommands.LogOutCommand">
        <Viewbox Width="15">
            <Image Source="..ResourcesLogout.png"/>
        </Viewbox>
    </Button>
    <Button Command="com:FormatCommands.GetTodaysRacesCommand">
        <Viewbox Width="15">
            <Image Source="..Resourceslist.png"/>
        </Viewbox>
    </Button>
    <Menu>
        <MenuItem Header="Markets">
            <MenuItem IsCheckable="True" Header="British"/>
            <MenuItem IsCheckable="True" Header="Irish" />
        </MenuItem>
    </Menu>            
</ToolBar>

推荐答案

ToolBar 元素为一些控件定义了一些样式,Menu 就是其中之一.您可以在 ToolBar.MenuStyleKey 静态属性中找到定义的 Style 键.该样式将包含复选标记的面板的 Background 设置为 #FF212121.

The ToolBar element defines some styles for a few controls and the Menu is one of them. You can find the Style key defined in the ToolBar.MenuStyleKey static property. That style is setting the Background to #FF212121 for the Panel which contains the check mark.

不幸的是,我不相信有一种方法可以只更改复选标记面板的背景,您将不得不覆盖那个难看的 MenuItem 样式.

Unfortunately i don't believe that there is a way to change only the background for the check mark's panel, you will have to override that ugly looking MenuItem style.

注意:要在您的案例中应用样式,请按照以下步骤操作:

Note: to get the style applied in your case follow this steps:

  1. 在新的 VS 解决方案中复制上述 XAML.
  2. 在设计器窗口中选择Menu.
  3. 右键单击菜单/编辑模板/编辑副本/回车.
  1. Copy the above XAML in a new VS solution.
  2. Select the Menu in the designer window.
  3. Right click on the Menu/ Edit Template / Edit a copy / Enter.

这篇关于选中在菜单中显示为黑框的标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆