Check Mark Showing as a Black Box in Menu

霸气de小男生 提交于 2019-12-20 01:09:05

问题


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.

Can anyone help?

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="..\Resources\Login.png"/>
        </Viewbox>                        
    </Button>
    <Button Command="com:FormatCommands.LogOutCommand">
        <Viewbox Width="15">
            <Image Source="..\Resources\Logout.png"/>
        </Viewbox>
    </Button>
    <Button Command="com:FormatCommands.GetTodaysRacesCommand">
        <Viewbox Width="15">
            <Image Source="..\Resources\list.png"/>
        </Viewbox>
    </Button>
    <Menu>
        <MenuItem Header="Markets">
            <MenuItem IsCheckable="True" Header="British"/>
            <MenuItem IsCheckable="True" Header="Irish" />
        </MenuItem>
    </Menu>            
</ToolBar>

回答1:


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.

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. 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.


来源:https://stackoverflow.com/questions/20643480/check-mark-showing-as-a-black-box-in-menu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!