0

I've the WPF application that has MahApps Metro library embedded for more beautiful appearance.

What bothers me is ListViewItem colour on borders of it when I hover over it. So I want to change it. Only solutions I've found are something like this:

<ListView.Resources>
<Style TargetType="TextBlock">
  <Style.Triggers>
    <DataTrigger Binding="{Binding IsSelected, RelativeSourcValue="True">
      <Setter Property="Foreground" Value="White" />
    </Trigger>
  </Style.Triggers>
    </Style>
  </ListView.Resources>
  <ListView.ItemContainerStyle>
  <Style TargetType="ListViewItem" x:Key="ContainerStyle">
  <Style.Triggers>
    <Trigger Property="IsSelected" Value="True">
      <Setter Property="Background" Value="Red" />
    </Trigger>
  </Style.Triggers>
</Style>
</ListView.ItemContainerStyle>

But it doesn't work for me and what is interesting - the 'borderthichness' actually overrides, but not colour. I'm also fairly new to WPF, so I can't wrap my mind around what should be done in order to just change hover over colour of the borders? If anyone got an idea, please instruct me.

Monstryyy
  • 81
  • 9
  • maybe duplicate of https://stackoverflow.com/questions/38152912/change-listviewitem-background-colour-on-mouse-over – Mardukar May 17 '18 at 14:20
  • *"fairly new to WPF"* - have you hit your head with [precedence](https://learn.microsoft.com/en-us/dotnet/framework/wpf/advanced/dependency-property-value-precedence) already? Maybe you are doing it right now. – Sinatr May 17 '18 at 14:25
  • Colour of the borders? Please provide a screenshot of what you are currently seeing. – mm8 May 17 '18 at 14:32

1 Answers1

0

MahApps re-templates the controls, so some of the normal tricks don't work. You'll have to modify the template to get the style changes you want.

The template can be found here:

https://github.com/MahApps/MahApps.Metro/blob/develop/src/MahApps.Metro/Styles/Controls.ListView.xaml

Jacquers
  • 179
  • 1
  • 4