Klay
Klay

Reputation: 2011

Set ComboBox selected item highlight color

I need to change the highlight color of a ComboBox's selected item in the popup list. I've found several tutorials explaining how to do this, but all of them either use Blend, which I do not have and cannot obtain, or involve changing the system default colors--which seems like a hack to me.

Can someone point me to the template I need to override, or tell me the property I need to set?

Upvotes: 15

Views: 26306

Answers (2)

Kent Boogaart
Kent Boogaart

Reputation: 178660

Override the SystemColors.HighlightBrushKey (and SystemColors.HighlightTextBrushKey if you want):

<ComboBox>
    <ComboBox.Resources>
        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}">Red</SolidColorBrush>
        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}">Blue</SolidColorBrush>
    </ComboBox.Resources>
    <ComboBoxItem>One</ComboBoxItem>
    <ComboBoxItem>Two</ComboBoxItem>
</ComboBox>

Upvotes: 25

Vikas bhandari
Vikas bhandari

Reputation:

I have created a template for Combobox here :

http://wpfstyles.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=31388#DownloadId=78720

Thanks, Vikas

Upvotes: 0

Related Questions