C# WPF ComboBox Mouse over color

前端 未结 4 1667
后悔当初
后悔当初 2021-01-18 07:49

When the mouse hover over my ComboBox, I get an awful blue/lightblue pair of color for the backgroung of my ComboBox. I tried the solutions here :ComboBox Mouse over color,

4条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-18 08:45

    you can override SystemColors.HighlightBrushKey within the ComboBox scope:

    
        
    
    

    sample

    the entire XAML can be something like this:

    
        
            
                
            
            
                
            
        
    
    

    A followup to your comment:

    ignore the viewmodel and my ItemSource you should use your own, this was just for the demonstration.

    as for your comment about

    I could not get anything to work

    i would suggest that you will create a new project and test only this XAML (with your ItemSource of course) and see if you can get the result you want. when you will get that, you can move to your real project and see where the styles changes and where is the problem exists.

    EDIT#2:

    In order to change the color of the ToggleButton i think is best to override the entire ComboBox Style.

    enter image description here

    i used the

     
    

    The rest of the code and style taken from here.

    i would recommend you to read this as well.

提交回复
热议问题