0

I have a buttons in process flow shape, which looks nice but on hover the ugly blue highlights appear underneath. How can I remove it?

Button 2 is highlighted:

enter image description here

Resource Dictionary:

<Style x:Key="ButtonStyleMainRed" TargetType="{x:Type Button}">
    <Setter Property="Background" Value="#37474f"/>
    <Setter Property="HorizontalAlignment" Value="Center"/>
    <Setter Property="VerticalContentAlignment" Value="Top"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type Button}">
                <Grid>
                    <Path Fill="{TemplateBinding Background}"
                        Data="F1 M 0.78429,0.50002L 128.79,0.50002L 161.069,32.7785L 129.055,64.7919L 0.500001,64.7919L 32.5214,32.7705L 0.516563,0.765584" />
                    <TextBlock Text="Test"  
                                   VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="14" Foreground="White" TextWrapping="WrapWithOverflow"/>
                    <Rectangle Name="Led" Width="50" Height="4" Fill="#d50000" Margin="0,40,0,0" RadiusX="2" RadiusY="2"/>
                </Grid>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsFocused" Value="True"/>
                    <Trigger Property="IsDefaulted" Value="True"/>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="Background" Value="#263238"></Setter>
                        <Setter TargetName="Led" Property="Fill" Value="#f44336"></Setter>
                    </Trigger>
                    <Trigger Property="IsPressed" Value="True"/>
                    <Trigger Property="IsEnabled" Value="False"/>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

View:

<views:BaseView.Resources>
    <DataTemplate x:Key="FlowStageTemplate">
        <StackPanel>
            <Button x:Name="ProcessStageButton" 
                    Tag="{Binding ID}"
                    Command="{Binding DataContext.OnButtonClickCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" 
                    CommandParameter="{Binding ElementName=TurulStageButton}"
                    Style="{Binding FlowStageDisplayStyle}"
                    Width="160" Height="65" Margin="0,0,-24,0" >
            </Button>
        </StackPanel>
    </DataTemplate>
</views:BaseView.Resources>
<StackPanel>
    <ListView ItemsSource="{Binding FlowStagesMainMenu}" ItemTemplate="{StaticResource FlowStageTemplate}" 
              Height="67" BorderThickness="0" Background="#263238" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
        <ListView.ItemContainerStyle>
            <Style TargetType="ListViewItem">
                <Setter Property="Padding" Value="0"/>
                <Setter Property="Margin" Value="0"/>
                <Setter Property="BorderThickness" Value="0"/>
            </Style>
        </ListView.ItemContainerStyle>
        <ListView.Resources>
            <SolidColorBrush x:Key="ItemBackgroundHover" Color="Transparent" />
            <SolidColorBrush x:Key="ItemBackgroundSelected" Color="Transparent" />
        </ListView.Resources>
        <ListView.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel Orientation="Horizontal"/>
            </ItemsPanelTemplate>
        </ListView.ItemsPanel>
    </ListView>
</StackPanel>

I have tried to hide it by the below, but no change:

<SolidColorBrush x:Key="ItemBackgroundHover" Color="Transparent" />
<SolidColorBrush x:Key="ItemBackgroundSelected" Color="Transparent" />
Whistler
  • 1,897
  • 4
  • 29
  • 50
  • Strange, I tried to reproduce and it looks well. I only replaced in your `FlowStageTemplate` code one line: ` Style="{Binding FlowStageDisplayStyle}"` I replaced with ` Style="{Binding FlowStageDisplayStyle}"`. No highliht on hover, but I got blue highlight on right click. Seems like you didn't override default selection style. – lena Mar 16 '16 at 11:11
  • I added `` in a `ListViewItem` style, it fixed this behaviour – lena Mar 16 '16 at 11:15
  • What did you replace it for in the first comment? You placed twice: Style="{Binding FlowStageDisplayStyle}" – Whistler Mar 16 '16 at 11:27
  • ah sorry wrong copy-paste. it should be `Style="{StaticResource ButtonStyleMainRed}"` – lena Mar 16 '16 at 11:33
  • it doesn't work for me, still see the blue highlight on the background – Whistler Mar 16 '16 at 11:36
  • I also placed `ButtonStyleMainRed` right before `FlowStageTemplate`. That's weird. – lena Mar 16 '16 at 11:38
  • ButtonStyleMainRed is in ResourceDictionary and FlowStagesTemplate is on the View so cant really rearrange it. Could you send me your sample project? maybe that give me an idea what is wrong – Whistler Mar 16 '16 at 11:46
  • https://cloud.mail.ru/public/Ciwt/T7rwRbefE – lena Mar 16 '16 at 11:50
  • can you please clarify how exactly the code you posted arranged in files? – lena Mar 16 '16 at 11:50
  • I moved `ButtonStyleMainRed ` to a separate file, included it with ` ` and moved `FlowStageTemplate` to `StackPanel.Resources`. Still works fine. – lena Mar 16 '16 at 11:54
  • Your example have exactly the same issue. Would that be Win 10? – Whistler Mar 16 '16 at 11:54
  • So I'm assuming this is a metro style issue. I need this to work on all Windows exactly the same – Whistler Mar 16 '16 at 11:57
  • Sorry I have no Win10 machine, can't help you here. Good luck anyway. At least you know where to dig now. – lena Mar 16 '16 at 12:00
  • Thanks for your help – Whistler Mar 16 '16 at 12:00
  • You'll just need to edit a listviewitem template to fit your needs. If you do that while you're in there you can do the stuff you're doing in your itemcontainerstyle directly to it and get rid of that part. – Chris W. Mar 16 '16 at 13:54
  • this is what I don't understand how to do it – Whistler Mar 16 '16 at 13:58
  • This might help you: http://stackoverflow.com/questions/31162264/remove-blue-highlight-on-buttons-wpf – MarkusE Mar 16 '16 at 14:54
  • That is not the same, there is about button, here is more about the ListViewItem – Whistler Mar 16 '16 at 14:57

0 Answers0