SelectedItem color of listview and comboboxHow do I get the color from a hexadecimal color code using .NET?Displaying FontFamily in Comboboxcombo box inside a user control disappears when style is applied in wpfHow to modify legacy named style for having different setters based on targetTypes?VS 2012 App.xaml Implicit Styling IssueHow to apply different ResourceDictionary Styles asynchronously every 5 seconds?WPF Button Style Background hidding ForegroundWPF ControlTemplate TargetType matchMaking a WPF combobox with rounded cornersText color in wpf listview

Counterexample finite intersection property

Can a warlock shoot multiple beams from the Eldritch Blast cantrip with only a single free hand?

Strange LED behavior

Why is DC so, so, so Democratic?

What kind of vegetable has pink and white concentric rings?

How did pilots avoid thunderstorms and related weather before “reliable” airborne weather radar was introduced on airliners?

How do you structure large embedded projects?

How to pass array of values in lualatex?

What is the best word describing the nature of expiring in a short amount of time, connoting "losing public attention"?

Is it better to merge "often" or only after completion do a big merge of feature branches?

My current job follows "worst practices". How can I talk about my experience in an interview without giving off red flags?

MITM on HTTPS traffic in Kazakhstan 2019

Can a creature sustain itself by eating its own severed body parts?

Why is the UH-60 tail rotor canted?

On a Gameboy, what happens when attempting to read/write external RAM while RAM is disabled?

Why are the phonemes of Tutankhamun's throne name transliterated out of order?

Why did computer video outputs go from digital to analog, then back to digital?

Are there any English words pronounced with sounds/syllables that aren't part of the spelling?

Is it better to deliver many low-value stories or few high-value stories?

Capture SQL Server queries without third-party tooling and without using deprecated features?

Cargo capacity of a kayak

Host telling me to cancel my booking in exchange for a discount?

Found more old paper shares from broken up companies

Oriented vector bundle with odd-dimensional fibers



SelectedItem color of listview and combobox


How do I get the color from a hexadecimal color code using .NET?Displaying FontFamily in Comboboxcombo box inside a user control disappears when style is applied in wpfHow to modify legacy named style for having different setters based on targetTypes?VS 2012 App.xaml Implicit Styling IssueHow to apply different ResourceDictionary Styles asynchronously every 5 seconds?WPF Button Style Background hidding ForegroundWPF ControlTemplate TargetType matchMaking a WPF combobox with rounded cornersText color in wpf listview






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















How can I modify the SelectedItem background color (and / or foreground color) of a ListView and ComboBoxes at the same time? (in WPF and XAML files)



In my app, I have a ListView and many ComboBoxes, but when I click an item, it highlights with blue, and the text becomes unreadable. Look at the image below for example (it's the same for ComboBoxes).



example



My app has 3 differents XAML resource files (for skins), but none of these implement a template of ListViews or ComboBoxes. I don't want to develop a full ListBox and ComboBox template just for this :(



My app.xaml is very simple :



<Application.Resources>
<ResourceDictionary>
<Style TargetType="Label" >
<Setter Property="FontSize" Value="10" />
<Setter Property="FontFamily" Value="Verdana" />
<Setter Property="Foreground" Value="DynamicResource Foreground" />
</Style>
<Style TargetType="Button" >
<Setter Property="Template" Value="DynamicResource ButtonControlTemplate1" />
</Style>

<ResourceDictionary.MergedDictionaries>
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
<!-- Accent and AppTheme setting -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
<ResourceDictionary x:Name="Default" Source="resDefault.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>


For information, I'm using Blend for design purposes.










share|improve this question






























    0















    How can I modify the SelectedItem background color (and / or foreground color) of a ListView and ComboBoxes at the same time? (in WPF and XAML files)



    In my app, I have a ListView and many ComboBoxes, but when I click an item, it highlights with blue, and the text becomes unreadable. Look at the image below for example (it's the same for ComboBoxes).



    example



    My app has 3 differents XAML resource files (for skins), but none of these implement a template of ListViews or ComboBoxes. I don't want to develop a full ListBox and ComboBox template just for this :(



    My app.xaml is very simple :



    <Application.Resources>
    <ResourceDictionary>
    <Style TargetType="Label" >
    <Setter Property="FontSize" Value="10" />
    <Setter Property="FontFamily" Value="Verdana" />
    <Setter Property="Foreground" Value="DynamicResource Foreground" />
    </Style>
    <Style TargetType="Button" >
    <Setter Property="Template" Value="DynamicResource ButtonControlTemplate1" />
    </Style>

    <ResourceDictionary.MergedDictionaries>
    <!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
    <!-- Accent and AppTheme setting -->
    <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
    <ResourceDictionary x:Name="Default" Source="resDefault.xaml"/>
    </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
    </Application.Resources>


    For information, I'm using Blend for design purposes.










    share|improve this question


























      0












      0








      0








      How can I modify the SelectedItem background color (and / or foreground color) of a ListView and ComboBoxes at the same time? (in WPF and XAML files)



      In my app, I have a ListView and many ComboBoxes, but when I click an item, it highlights with blue, and the text becomes unreadable. Look at the image below for example (it's the same for ComboBoxes).



      example



      My app has 3 differents XAML resource files (for skins), but none of these implement a template of ListViews or ComboBoxes. I don't want to develop a full ListBox and ComboBox template just for this :(



      My app.xaml is very simple :



      <Application.Resources>
      <ResourceDictionary>
      <Style TargetType="Label" >
      <Setter Property="FontSize" Value="10" />
      <Setter Property="FontFamily" Value="Verdana" />
      <Setter Property="Foreground" Value="DynamicResource Foreground" />
      </Style>
      <Style TargetType="Button" >
      <Setter Property="Template" Value="DynamicResource ButtonControlTemplate1" />
      </Style>

      <ResourceDictionary.MergedDictionaries>
      <!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
      <!-- Accent and AppTheme setting -->
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
      <ResourceDictionary x:Name="Default" Source="resDefault.xaml"/>
      </ResourceDictionary.MergedDictionaries>
      </ResourceDictionary>
      </Application.Resources>


      For information, I'm using Blend for design purposes.










      share|improve this question
















      How can I modify the SelectedItem background color (and / or foreground color) of a ListView and ComboBoxes at the same time? (in WPF and XAML files)



      In my app, I have a ListView and many ComboBoxes, but when I click an item, it highlights with blue, and the text becomes unreadable. Look at the image below for example (it's the same for ComboBoxes).



      example



      My app has 3 differents XAML resource files (for skins), but none of these implement a template of ListViews or ComboBoxes. I don't want to develop a full ListBox and ComboBox template just for this :(



      My app.xaml is very simple :



      <Application.Resources>
      <ResourceDictionary>
      <Style TargetType="Label" >
      <Setter Property="FontSize" Value="10" />
      <Setter Property="FontFamily" Value="Verdana" />
      <Setter Property="Foreground" Value="DynamicResource Foreground" />
      </Style>
      <Style TargetType="Button" >
      <Setter Property="Template" Value="DynamicResource ButtonControlTemplate1" />
      </Style>

      <ResourceDictionary.MergedDictionaries>
      <!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
      <!-- Accent and AppTheme setting -->
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
      <ResourceDictionary x:Name="Default" Source="resDefault.xaml"/>
      </ResourceDictionary.MergedDictionaries>
      </ResourceDictionary>
      </Application.Resources>


      For information, I'm using Blend for design purposes.







      c# wpf user-interface






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 26 at 14:51









      Pierre-Loup Pagniez

      2,1301 gold badge21 silver badges27 bronze badges




      2,1301 gold badge21 silver badges27 bronze badges










      asked Mar 26 at 13:37









      RemsRems

      286 bronze badges




      286 bronze badges






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I notice you are using MahApps as design, then you have to override MahApps ComboBoxItem and modify their backgroud color. Here is the original MetroComboBoxItem and use BackGroundColorBrush for color, but you can replace it with your blend style



          <SolidColorBrush x:Key="BackGroundColorBrush" Color="DeepPink" />
          <Style x:Key="MetroComboBoxItem" TargetType="ComboBoxItem">
          <Setter Property="Background" Value="DynamicResource WhiteBrush" />
          <Setter Property="BorderThickness" Value="0" />
          <Setter Property="Controls:ItemHelper.ActiveSelectionBackgroundBrush" Value="DynamicResource AccentColorBrush" />
          <Setter Property="Controls:ItemHelper.ActiveSelectionForegroundBrush" Value="DynamicResource AccentSelectedColorBrush" />
          <Setter Property="Controls:ItemHelper.DisabledForegroundBrush" Value="DynamicResource GrayNormalBrush" />
          <Setter Property="Controls:ItemHelper.DisabledSelectedBackgroundBrush" Value="DynamicResource GrayBrush7" />
          <Setter Property="Controls:ItemHelper.DisabledSelectedForegroundBrush" Value="DynamicResource AccentSelectedColorBrush" />
          <Setter Property="Controls:ItemHelper.HoverBackgroundBrush" Value="DynamicResource AccentColorBrush3" />
          <Setter Property="Controls:ItemHelper.HoverSelectedBackgroundBrush" Value="DynamicResource AccentColorBrush" />
          <Setter Property="Controls:ItemHelper.SelectedBackgroundBrush" Value="DynamicResource AccentColorBrush2" />
          <Setter Property="Controls:ItemHelper.SelectedForegroundBrush" Value="DynamicResource AccentSelectedColorBrush" />
          <Setter Property="Foreground" Value="DynamicResource TextBrush" />
          <Setter Property="HorizontalContentAlignment" Value="Left" />
          <Setter Property="MinHeight" Value="22" />
          <Setter Property="Padding" Value="2" />
          <Setter Property="SnapsToDevicePixels" Value="True" />
          <Setter Property="Template">
          <Setter.Value>
          <ControlTemplate TargetType="ComboBoxItem">
          <--here is what you need to change-->
          <Grid Background="DynamicResource BackGroundColorBrush" RenderOptions.ClearTypeHint="TemplateBinding RenderOptions.ClearTypeHint">
          <Border x:Name="Border"
          Background="TemplateBinding Background"
          BorderBrush="TemplateBinding BorderBrush"
          BorderThickness="TemplateBinding BorderThickness"
          SnapsToDevicePixels="TemplateBinding SnapsToDevicePixels" />
          <Grid Margin="TemplateBinding BorderThickness">
          <ContentPresenter x:Name="contentPresenter"
          Margin="TemplateBinding Padding"
          HorizontalAlignment="TemplateBinding HorizontalContentAlignment"
          VerticalAlignment="TemplateBinding VerticalContentAlignment"
          SnapsToDevicePixels="TemplateBinding SnapsToDevicePixels" />
          </Grid>
          </Grid>
          <ControlTemplate.Triggers>
          <Trigger Property="IsSelected" Value="True">
          <Setter Property="Foreground" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.SelectedForegroundBrush), Mode=OneWay" />
          <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource TemplatedParent, Path=(Controls:ItemHelper.SelectedBackgroundBrush), Mode=OneWay" />
          </Trigger>
          <MultiTrigger>
          <MultiTrigger.Conditions>
          <Condition Property="IsSelected" Value="True" />
          <Condition Property="Selector.IsSelectionActive" Value="True" />
          </MultiTrigger.Conditions>
          <Setter Property="Foreground" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.ActiveSelectionForegroundBrush), Mode=OneWay" />
          <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource TemplatedParent, Path=(Controls:ItemHelper.ActiveSelectionBackgroundBrush), Mode=OneWay" />
          </MultiTrigger>

          <MultiTrigger>
          <MultiTrigger.Conditions>
          <Condition Property="IsMouseOver" Value="True" />
          <Condition Property="IsSelected" Value="True" />
          </MultiTrigger.Conditions>
          <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource TemplatedParent, Path=(Controls:ItemHelper.HoverSelectedBackgroundBrush), Mode=OneWay" />
          </MultiTrigger>
          <MultiTrigger>
          <MultiTrigger.Conditions>
          <Condition Property="IsMouseOver" Value="True" />
          <Condition Property="IsSelected" Value="False" />
          </MultiTrigger.Conditions>
          <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource TemplatedParent, Path=(Controls:ItemHelper.HoverBackgroundBrush), Mode=OneWay" />
          </MultiTrigger>

          <Trigger Property="IsEnabled" Value="False">
          <Setter Property="Foreground" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.DisabledForegroundBrush), Mode=OneWay" />
          <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.DisabledBackgroundBrush), Mode=OneWay" />
          </Trigger>
          <MultiTrigger>
          <MultiTrigger.Conditions>
          <Condition Property="IsEnabled" Value="False" />
          <Condition Property="IsSelected" Value="True" />
          </MultiTrigger.Conditions>
          <Setter Property="Foreground" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.DisabledSelectedForegroundBrush), Mode=OneWay" />
          <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.DisabledSelectedBackgroundBrush), Mode=OneWay" />
          </MultiTrigger>
          </ControlTemplate.Triggers>
          </ControlTemplate>
          </Setter.Value>
          </Setter>
          <Setter Property="VerticalContentAlignment" Value="Center" />
          <Style.Triggers>
          <Trigger Property="IsVisible" Value="True">
          <Setter Property="RenderOptions.ClearTypeHint" Value="Binding Path=(RenderOptions.ClearTypeHint), FallbackValue=Auto, RelativeSource=RelativeSource FindAncestor, AncestorType=x:Type ComboBox" />
          </Trigger>
          </Style.Triggers>
          </Style>





          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55358540%2fselecteditem-color-of-listview-and-combobox%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I notice you are using MahApps as design, then you have to override MahApps ComboBoxItem and modify their backgroud color. Here is the original MetroComboBoxItem and use BackGroundColorBrush for color, but you can replace it with your blend style



            <SolidColorBrush x:Key="BackGroundColorBrush" Color="DeepPink" />
            <Style x:Key="MetroComboBoxItem" TargetType="ComboBoxItem">
            <Setter Property="Background" Value="DynamicResource WhiteBrush" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="Controls:ItemHelper.ActiveSelectionBackgroundBrush" Value="DynamicResource AccentColorBrush" />
            <Setter Property="Controls:ItemHelper.ActiveSelectionForegroundBrush" Value="DynamicResource AccentSelectedColorBrush" />
            <Setter Property="Controls:ItemHelper.DisabledForegroundBrush" Value="DynamicResource GrayNormalBrush" />
            <Setter Property="Controls:ItemHelper.DisabledSelectedBackgroundBrush" Value="DynamicResource GrayBrush7" />
            <Setter Property="Controls:ItemHelper.DisabledSelectedForegroundBrush" Value="DynamicResource AccentSelectedColorBrush" />
            <Setter Property="Controls:ItemHelper.HoverBackgroundBrush" Value="DynamicResource AccentColorBrush3" />
            <Setter Property="Controls:ItemHelper.HoverSelectedBackgroundBrush" Value="DynamicResource AccentColorBrush" />
            <Setter Property="Controls:ItemHelper.SelectedBackgroundBrush" Value="DynamicResource AccentColorBrush2" />
            <Setter Property="Controls:ItemHelper.SelectedForegroundBrush" Value="DynamicResource AccentSelectedColorBrush" />
            <Setter Property="Foreground" Value="DynamicResource TextBrush" />
            <Setter Property="HorizontalContentAlignment" Value="Left" />
            <Setter Property="MinHeight" Value="22" />
            <Setter Property="Padding" Value="2" />
            <Setter Property="SnapsToDevicePixels" Value="True" />
            <Setter Property="Template">
            <Setter.Value>
            <ControlTemplate TargetType="ComboBoxItem">
            <--here is what you need to change-->
            <Grid Background="DynamicResource BackGroundColorBrush" RenderOptions.ClearTypeHint="TemplateBinding RenderOptions.ClearTypeHint">
            <Border x:Name="Border"
            Background="TemplateBinding Background"
            BorderBrush="TemplateBinding BorderBrush"
            BorderThickness="TemplateBinding BorderThickness"
            SnapsToDevicePixels="TemplateBinding SnapsToDevicePixels" />
            <Grid Margin="TemplateBinding BorderThickness">
            <ContentPresenter x:Name="contentPresenter"
            Margin="TemplateBinding Padding"
            HorizontalAlignment="TemplateBinding HorizontalContentAlignment"
            VerticalAlignment="TemplateBinding VerticalContentAlignment"
            SnapsToDevicePixels="TemplateBinding SnapsToDevicePixels" />
            </Grid>
            </Grid>
            <ControlTemplate.Triggers>
            <Trigger Property="IsSelected" Value="True">
            <Setter Property="Foreground" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.SelectedForegroundBrush), Mode=OneWay" />
            <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource TemplatedParent, Path=(Controls:ItemHelper.SelectedBackgroundBrush), Mode=OneWay" />
            </Trigger>
            <MultiTrigger>
            <MultiTrigger.Conditions>
            <Condition Property="IsSelected" Value="True" />
            <Condition Property="Selector.IsSelectionActive" Value="True" />
            </MultiTrigger.Conditions>
            <Setter Property="Foreground" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.ActiveSelectionForegroundBrush), Mode=OneWay" />
            <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource TemplatedParent, Path=(Controls:ItemHelper.ActiveSelectionBackgroundBrush), Mode=OneWay" />
            </MultiTrigger>

            <MultiTrigger>
            <MultiTrigger.Conditions>
            <Condition Property="IsMouseOver" Value="True" />
            <Condition Property="IsSelected" Value="True" />
            </MultiTrigger.Conditions>
            <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource TemplatedParent, Path=(Controls:ItemHelper.HoverSelectedBackgroundBrush), Mode=OneWay" />
            </MultiTrigger>
            <MultiTrigger>
            <MultiTrigger.Conditions>
            <Condition Property="IsMouseOver" Value="True" />
            <Condition Property="IsSelected" Value="False" />
            </MultiTrigger.Conditions>
            <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource TemplatedParent, Path=(Controls:ItemHelper.HoverBackgroundBrush), Mode=OneWay" />
            </MultiTrigger>

            <Trigger Property="IsEnabled" Value="False">
            <Setter Property="Foreground" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.DisabledForegroundBrush), Mode=OneWay" />
            <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.DisabledBackgroundBrush), Mode=OneWay" />
            </Trigger>
            <MultiTrigger>
            <MultiTrigger.Conditions>
            <Condition Property="IsEnabled" Value="False" />
            <Condition Property="IsSelected" Value="True" />
            </MultiTrigger.Conditions>
            <Setter Property="Foreground" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.DisabledSelectedForegroundBrush), Mode=OneWay" />
            <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.DisabledSelectedBackgroundBrush), Mode=OneWay" />
            </MultiTrigger>
            </ControlTemplate.Triggers>
            </ControlTemplate>
            </Setter.Value>
            </Setter>
            <Setter Property="VerticalContentAlignment" Value="Center" />
            <Style.Triggers>
            <Trigger Property="IsVisible" Value="True">
            <Setter Property="RenderOptions.ClearTypeHint" Value="Binding Path=(RenderOptions.ClearTypeHint), FallbackValue=Auto, RelativeSource=RelativeSource FindAncestor, AncestorType=x:Type ComboBox" />
            </Trigger>
            </Style.Triggers>
            </Style>





            share|improve this answer



























              0














              I notice you are using MahApps as design, then you have to override MahApps ComboBoxItem and modify their backgroud color. Here is the original MetroComboBoxItem and use BackGroundColorBrush for color, but you can replace it with your blend style



              <SolidColorBrush x:Key="BackGroundColorBrush" Color="DeepPink" />
              <Style x:Key="MetroComboBoxItem" TargetType="ComboBoxItem">
              <Setter Property="Background" Value="DynamicResource WhiteBrush" />
              <Setter Property="BorderThickness" Value="0" />
              <Setter Property="Controls:ItemHelper.ActiveSelectionBackgroundBrush" Value="DynamicResource AccentColorBrush" />
              <Setter Property="Controls:ItemHelper.ActiveSelectionForegroundBrush" Value="DynamicResource AccentSelectedColorBrush" />
              <Setter Property="Controls:ItemHelper.DisabledForegroundBrush" Value="DynamicResource GrayNormalBrush" />
              <Setter Property="Controls:ItemHelper.DisabledSelectedBackgroundBrush" Value="DynamicResource GrayBrush7" />
              <Setter Property="Controls:ItemHelper.DisabledSelectedForegroundBrush" Value="DynamicResource AccentSelectedColorBrush" />
              <Setter Property="Controls:ItemHelper.HoverBackgroundBrush" Value="DynamicResource AccentColorBrush3" />
              <Setter Property="Controls:ItemHelper.HoverSelectedBackgroundBrush" Value="DynamicResource AccentColorBrush" />
              <Setter Property="Controls:ItemHelper.SelectedBackgroundBrush" Value="DynamicResource AccentColorBrush2" />
              <Setter Property="Controls:ItemHelper.SelectedForegroundBrush" Value="DynamicResource AccentSelectedColorBrush" />
              <Setter Property="Foreground" Value="DynamicResource TextBrush" />
              <Setter Property="HorizontalContentAlignment" Value="Left" />
              <Setter Property="MinHeight" Value="22" />
              <Setter Property="Padding" Value="2" />
              <Setter Property="SnapsToDevicePixels" Value="True" />
              <Setter Property="Template">
              <Setter.Value>
              <ControlTemplate TargetType="ComboBoxItem">
              <--here is what you need to change-->
              <Grid Background="DynamicResource BackGroundColorBrush" RenderOptions.ClearTypeHint="TemplateBinding RenderOptions.ClearTypeHint">
              <Border x:Name="Border"
              Background="TemplateBinding Background"
              BorderBrush="TemplateBinding BorderBrush"
              BorderThickness="TemplateBinding BorderThickness"
              SnapsToDevicePixels="TemplateBinding SnapsToDevicePixels" />
              <Grid Margin="TemplateBinding BorderThickness">
              <ContentPresenter x:Name="contentPresenter"
              Margin="TemplateBinding Padding"
              HorizontalAlignment="TemplateBinding HorizontalContentAlignment"
              VerticalAlignment="TemplateBinding VerticalContentAlignment"
              SnapsToDevicePixels="TemplateBinding SnapsToDevicePixels" />
              </Grid>
              </Grid>
              <ControlTemplate.Triggers>
              <Trigger Property="IsSelected" Value="True">
              <Setter Property="Foreground" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.SelectedForegroundBrush), Mode=OneWay" />
              <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource TemplatedParent, Path=(Controls:ItemHelper.SelectedBackgroundBrush), Mode=OneWay" />
              </Trigger>
              <MultiTrigger>
              <MultiTrigger.Conditions>
              <Condition Property="IsSelected" Value="True" />
              <Condition Property="Selector.IsSelectionActive" Value="True" />
              </MultiTrigger.Conditions>
              <Setter Property="Foreground" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.ActiveSelectionForegroundBrush), Mode=OneWay" />
              <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource TemplatedParent, Path=(Controls:ItemHelper.ActiveSelectionBackgroundBrush), Mode=OneWay" />
              </MultiTrigger>

              <MultiTrigger>
              <MultiTrigger.Conditions>
              <Condition Property="IsMouseOver" Value="True" />
              <Condition Property="IsSelected" Value="True" />
              </MultiTrigger.Conditions>
              <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource TemplatedParent, Path=(Controls:ItemHelper.HoverSelectedBackgroundBrush), Mode=OneWay" />
              </MultiTrigger>
              <MultiTrigger>
              <MultiTrigger.Conditions>
              <Condition Property="IsMouseOver" Value="True" />
              <Condition Property="IsSelected" Value="False" />
              </MultiTrigger.Conditions>
              <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource TemplatedParent, Path=(Controls:ItemHelper.HoverBackgroundBrush), Mode=OneWay" />
              </MultiTrigger>

              <Trigger Property="IsEnabled" Value="False">
              <Setter Property="Foreground" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.DisabledForegroundBrush), Mode=OneWay" />
              <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.DisabledBackgroundBrush), Mode=OneWay" />
              </Trigger>
              <MultiTrigger>
              <MultiTrigger.Conditions>
              <Condition Property="IsEnabled" Value="False" />
              <Condition Property="IsSelected" Value="True" />
              </MultiTrigger.Conditions>
              <Setter Property="Foreground" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.DisabledSelectedForegroundBrush), Mode=OneWay" />
              <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.DisabledSelectedBackgroundBrush), Mode=OneWay" />
              </MultiTrigger>
              </ControlTemplate.Triggers>
              </ControlTemplate>
              </Setter.Value>
              </Setter>
              <Setter Property="VerticalContentAlignment" Value="Center" />
              <Style.Triggers>
              <Trigger Property="IsVisible" Value="True">
              <Setter Property="RenderOptions.ClearTypeHint" Value="Binding Path=(RenderOptions.ClearTypeHint), FallbackValue=Auto, RelativeSource=RelativeSource FindAncestor, AncestorType=x:Type ComboBox" />
              </Trigger>
              </Style.Triggers>
              </Style>





              share|improve this answer

























                0












                0








                0







                I notice you are using MahApps as design, then you have to override MahApps ComboBoxItem and modify their backgroud color. Here is the original MetroComboBoxItem and use BackGroundColorBrush for color, but you can replace it with your blend style



                <SolidColorBrush x:Key="BackGroundColorBrush" Color="DeepPink" />
                <Style x:Key="MetroComboBoxItem" TargetType="ComboBoxItem">
                <Setter Property="Background" Value="DynamicResource WhiteBrush" />
                <Setter Property="BorderThickness" Value="0" />
                <Setter Property="Controls:ItemHelper.ActiveSelectionBackgroundBrush" Value="DynamicResource AccentColorBrush" />
                <Setter Property="Controls:ItemHelper.ActiveSelectionForegroundBrush" Value="DynamicResource AccentSelectedColorBrush" />
                <Setter Property="Controls:ItemHelper.DisabledForegroundBrush" Value="DynamicResource GrayNormalBrush" />
                <Setter Property="Controls:ItemHelper.DisabledSelectedBackgroundBrush" Value="DynamicResource GrayBrush7" />
                <Setter Property="Controls:ItemHelper.DisabledSelectedForegroundBrush" Value="DynamicResource AccentSelectedColorBrush" />
                <Setter Property="Controls:ItemHelper.HoverBackgroundBrush" Value="DynamicResource AccentColorBrush3" />
                <Setter Property="Controls:ItemHelper.HoverSelectedBackgroundBrush" Value="DynamicResource AccentColorBrush" />
                <Setter Property="Controls:ItemHelper.SelectedBackgroundBrush" Value="DynamicResource AccentColorBrush2" />
                <Setter Property="Controls:ItemHelper.SelectedForegroundBrush" Value="DynamicResource AccentSelectedColorBrush" />
                <Setter Property="Foreground" Value="DynamicResource TextBrush" />
                <Setter Property="HorizontalContentAlignment" Value="Left" />
                <Setter Property="MinHeight" Value="22" />
                <Setter Property="Padding" Value="2" />
                <Setter Property="SnapsToDevicePixels" Value="True" />
                <Setter Property="Template">
                <Setter.Value>
                <ControlTemplate TargetType="ComboBoxItem">
                <--here is what you need to change-->
                <Grid Background="DynamicResource BackGroundColorBrush" RenderOptions.ClearTypeHint="TemplateBinding RenderOptions.ClearTypeHint">
                <Border x:Name="Border"
                Background="TemplateBinding Background"
                BorderBrush="TemplateBinding BorderBrush"
                BorderThickness="TemplateBinding BorderThickness"
                SnapsToDevicePixels="TemplateBinding SnapsToDevicePixels" />
                <Grid Margin="TemplateBinding BorderThickness">
                <ContentPresenter x:Name="contentPresenter"
                Margin="TemplateBinding Padding"
                HorizontalAlignment="TemplateBinding HorizontalContentAlignment"
                VerticalAlignment="TemplateBinding VerticalContentAlignment"
                SnapsToDevicePixels="TemplateBinding SnapsToDevicePixels" />
                </Grid>
                </Grid>
                <ControlTemplate.Triggers>
                <Trigger Property="IsSelected" Value="True">
                <Setter Property="Foreground" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.SelectedForegroundBrush), Mode=OneWay" />
                <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource TemplatedParent, Path=(Controls:ItemHelper.SelectedBackgroundBrush), Mode=OneWay" />
                </Trigger>
                <MultiTrigger>
                <MultiTrigger.Conditions>
                <Condition Property="IsSelected" Value="True" />
                <Condition Property="Selector.IsSelectionActive" Value="True" />
                </MultiTrigger.Conditions>
                <Setter Property="Foreground" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.ActiveSelectionForegroundBrush), Mode=OneWay" />
                <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource TemplatedParent, Path=(Controls:ItemHelper.ActiveSelectionBackgroundBrush), Mode=OneWay" />
                </MultiTrigger>

                <MultiTrigger>
                <MultiTrigger.Conditions>
                <Condition Property="IsMouseOver" Value="True" />
                <Condition Property="IsSelected" Value="True" />
                </MultiTrigger.Conditions>
                <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource TemplatedParent, Path=(Controls:ItemHelper.HoverSelectedBackgroundBrush), Mode=OneWay" />
                </MultiTrigger>
                <MultiTrigger>
                <MultiTrigger.Conditions>
                <Condition Property="IsMouseOver" Value="True" />
                <Condition Property="IsSelected" Value="False" />
                </MultiTrigger.Conditions>
                <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource TemplatedParent, Path=(Controls:ItemHelper.HoverBackgroundBrush), Mode=OneWay" />
                </MultiTrigger>

                <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.DisabledForegroundBrush), Mode=OneWay" />
                <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.DisabledBackgroundBrush), Mode=OneWay" />
                </Trigger>
                <MultiTrigger>
                <MultiTrigger.Conditions>
                <Condition Property="IsEnabled" Value="False" />
                <Condition Property="IsSelected" Value="True" />
                </MultiTrigger.Conditions>
                <Setter Property="Foreground" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.DisabledSelectedForegroundBrush), Mode=OneWay" />
                <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.DisabledSelectedBackgroundBrush), Mode=OneWay" />
                </MultiTrigger>
                </ControlTemplate.Triggers>
                </ControlTemplate>
                </Setter.Value>
                </Setter>
                <Setter Property="VerticalContentAlignment" Value="Center" />
                <Style.Triggers>
                <Trigger Property="IsVisible" Value="True">
                <Setter Property="RenderOptions.ClearTypeHint" Value="Binding Path=(RenderOptions.ClearTypeHint), FallbackValue=Auto, RelativeSource=RelativeSource FindAncestor, AncestorType=x:Type ComboBox" />
                </Trigger>
                </Style.Triggers>
                </Style>





                share|improve this answer













                I notice you are using MahApps as design, then you have to override MahApps ComboBoxItem and modify their backgroud color. Here is the original MetroComboBoxItem and use BackGroundColorBrush for color, but you can replace it with your blend style



                <SolidColorBrush x:Key="BackGroundColorBrush" Color="DeepPink" />
                <Style x:Key="MetroComboBoxItem" TargetType="ComboBoxItem">
                <Setter Property="Background" Value="DynamicResource WhiteBrush" />
                <Setter Property="BorderThickness" Value="0" />
                <Setter Property="Controls:ItemHelper.ActiveSelectionBackgroundBrush" Value="DynamicResource AccentColorBrush" />
                <Setter Property="Controls:ItemHelper.ActiveSelectionForegroundBrush" Value="DynamicResource AccentSelectedColorBrush" />
                <Setter Property="Controls:ItemHelper.DisabledForegroundBrush" Value="DynamicResource GrayNormalBrush" />
                <Setter Property="Controls:ItemHelper.DisabledSelectedBackgroundBrush" Value="DynamicResource GrayBrush7" />
                <Setter Property="Controls:ItemHelper.DisabledSelectedForegroundBrush" Value="DynamicResource AccentSelectedColorBrush" />
                <Setter Property="Controls:ItemHelper.HoverBackgroundBrush" Value="DynamicResource AccentColorBrush3" />
                <Setter Property="Controls:ItemHelper.HoverSelectedBackgroundBrush" Value="DynamicResource AccentColorBrush" />
                <Setter Property="Controls:ItemHelper.SelectedBackgroundBrush" Value="DynamicResource AccentColorBrush2" />
                <Setter Property="Controls:ItemHelper.SelectedForegroundBrush" Value="DynamicResource AccentSelectedColorBrush" />
                <Setter Property="Foreground" Value="DynamicResource TextBrush" />
                <Setter Property="HorizontalContentAlignment" Value="Left" />
                <Setter Property="MinHeight" Value="22" />
                <Setter Property="Padding" Value="2" />
                <Setter Property="SnapsToDevicePixels" Value="True" />
                <Setter Property="Template">
                <Setter.Value>
                <ControlTemplate TargetType="ComboBoxItem">
                <--here is what you need to change-->
                <Grid Background="DynamicResource BackGroundColorBrush" RenderOptions.ClearTypeHint="TemplateBinding RenderOptions.ClearTypeHint">
                <Border x:Name="Border"
                Background="TemplateBinding Background"
                BorderBrush="TemplateBinding BorderBrush"
                BorderThickness="TemplateBinding BorderThickness"
                SnapsToDevicePixels="TemplateBinding SnapsToDevicePixels" />
                <Grid Margin="TemplateBinding BorderThickness">
                <ContentPresenter x:Name="contentPresenter"
                Margin="TemplateBinding Padding"
                HorizontalAlignment="TemplateBinding HorizontalContentAlignment"
                VerticalAlignment="TemplateBinding VerticalContentAlignment"
                SnapsToDevicePixels="TemplateBinding SnapsToDevicePixels" />
                </Grid>
                </Grid>
                <ControlTemplate.Triggers>
                <Trigger Property="IsSelected" Value="True">
                <Setter Property="Foreground" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.SelectedForegroundBrush), Mode=OneWay" />
                <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource TemplatedParent, Path=(Controls:ItemHelper.SelectedBackgroundBrush), Mode=OneWay" />
                </Trigger>
                <MultiTrigger>
                <MultiTrigger.Conditions>
                <Condition Property="IsSelected" Value="True" />
                <Condition Property="Selector.IsSelectionActive" Value="True" />
                </MultiTrigger.Conditions>
                <Setter Property="Foreground" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.ActiveSelectionForegroundBrush), Mode=OneWay" />
                <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource TemplatedParent, Path=(Controls:ItemHelper.ActiveSelectionBackgroundBrush), Mode=OneWay" />
                </MultiTrigger>

                <MultiTrigger>
                <MultiTrigger.Conditions>
                <Condition Property="IsMouseOver" Value="True" />
                <Condition Property="IsSelected" Value="True" />
                </MultiTrigger.Conditions>
                <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource TemplatedParent, Path=(Controls:ItemHelper.HoverSelectedBackgroundBrush), Mode=OneWay" />
                </MultiTrigger>
                <MultiTrigger>
                <MultiTrigger.Conditions>
                <Condition Property="IsMouseOver" Value="True" />
                <Condition Property="IsSelected" Value="False" />
                </MultiTrigger.Conditions>
                <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource TemplatedParent, Path=(Controls:ItemHelper.HoverBackgroundBrush), Mode=OneWay" />
                </MultiTrigger>

                <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.DisabledForegroundBrush), Mode=OneWay" />
                <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.DisabledBackgroundBrush), Mode=OneWay" />
                </Trigger>
                <MultiTrigger>
                <MultiTrigger.Conditions>
                <Condition Property="IsEnabled" Value="False" />
                <Condition Property="IsSelected" Value="True" />
                </MultiTrigger.Conditions>
                <Setter Property="Foreground" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.DisabledSelectedForegroundBrush), Mode=OneWay" />
                <Setter TargetName="Border" Property="Background" Value="Binding RelativeSource=RelativeSource Self, Path=(Controls:ItemHelper.DisabledSelectedBackgroundBrush), Mode=OneWay" />
                </MultiTrigger>
                </ControlTemplate.Triggers>
                </ControlTemplate>
                </Setter.Value>
                </Setter>
                <Setter Property="VerticalContentAlignment" Value="Center" />
                <Style.Triggers>
                <Trigger Property="IsVisible" Value="True">
                <Setter Property="RenderOptions.ClearTypeHint" Value="Binding Path=(RenderOptions.ClearTypeHint), FallbackValue=Auto, RelativeSource=RelativeSource FindAncestor, AncestorType=x:Type ComboBox" />
                </Trigger>
                </Style.Triggers>
                </Style>






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 26 at 14:39









                Sam XiaSam Xia

                268 bronze badges




                268 bronze badges


















                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55358540%2fselecteditem-color-of-listview-and-combobox%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript