Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is what I mean by checkbox (simplified code to avoid all confusing stuff):

XAML
<ToolBar IsManipulationEnabled="False">
                <Menu>
                    <MenuItem Header="Select file">
                        <MenuItem 
                            Click="BtnOpenFile_Click" 
                            IsChecked="{Binding IsFileSelected}" 
                            Header="File"/>
                    </MenuItem>
                </Menu>
            </ToolBar>


Normally WPF checkbox appears as empty or ticked.
For me it appears empty when not ticked (as it should):
https://i.stack.imgur.com/wkPE3.png

Black square when ticked (as it shouldn't):
https://i.stack.imgur.com/eK5aN.png

Normal "tick" when ticked and mouse hovers above (as it should, but all the time):
https://i.stack.imgur.com/kmAr8.png

I'm not using any 3rd party libraries for UI, it's default WPF. Is there a way to fix it? I'm almost certain that black square part is a glitch.

What I have tried:

A lot of googling but no one offers direct working solution.
Posted
Comments
Richard MacCutchan 4-May-21 8:58am    
The above code refers to a checked menu item, not a CheckBox.

However, the black square suggests that this is a Three-state CheckBox, and the current state is indeterminate.
Member 15047625 6-May-21 6:16am    
IsChecked is either true or false. Its WPF glitch, but it appears no one fixed it yet. Problematic.
George Swan 5-May-21 13:39pm    
There is an answer to your question here!
https://stackoverflow.com/questions/20643480/check-mark-showing-as-a-black-box-in-menu
Member 15047625 6-May-21 6:15am    
Setting Background to #FF212121 makes whole ToolBar black. Not exactly what I want to do.
Adérito Silva 31-Jul-21 17:32pm    
I don't know why this is happening, but it seems like something related with the MenuItem style/template. Are you using a custom MenuItem style or template? Are you using a custom CheckBox style or template?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900