0

I need to change a color in ComboBox WPF.For this I try override the template. But if I do this

<ComboBox.Template>
            <ControlTemplate>
                <Themes:SystemDropShadowChrome Color="Red"/>
            </ControlTemplate>
</ComboBox.Template>

It's just made a Red Cube that do nothing.All other properties of ComboBox are losted.So how to override template to change color and save properties of ComboBox?

Sneikof
  • 13
  • 4

3 Answers3

0

Did you try this;

<Setter Property="OverridesDefaultStyle" Value="true" />
0

You need to supply a new template, which is way more than just one line.

See the templates here:

https://learn.microsoft.com/en-us/dotnet/framework/wpf/controls/combobox-styles-and-templates

Andy
  • 11,864
  • 2
  • 17
  • 20
0

As per Microsoft's UG,

There is no way to replace only part of the visual tree of a control; to change the visual tree of a control you must set the Template property of the control to its new and complete ControlTemplate.

You need to describe the entire template of the control. Here is how you can get the full default template of a control : How to Extract Default Control Template In Visual Studio?

Mathivanan KP
  • 1,979
  • 16
  • 25