WPF Change Background color of a Combobox

前端 未结 5 602
逝去的感伤
逝去的感伤 2020-11-27 06:31

In my WPF app I just want to change the background color of the Combo box. I don\'t mean the dropdown, I want is just whatever item is selected a background is set. Like se

5条回答
  •  猫巷女王i
    2020-11-27 06:43

    While I like the accepted answer the problem I have with it is the text box presenter was completely missed and thus you can select and stylize things but they will never be presented to the end user. I think the easiest way to achieve a combo-box that shows data and then when chosen displays it would be this:

    
      
        
      
      
        
          Item1
          Item2
        
      
    
    

    The key parts of the presentation needed to be done is the template 'ToggleButton.Template' for the initial display. I chose to ignore making more brushes and links to more templates and just do it all inline so others could play with it as needed. I also chose what I thought were easily Identifiable colors to just jump to for reference it should look like below when it works:

提交回复
热议问题