C
C#2y ago
frknztrk

WPF Button controltemplate Icon Color

<Style x:Key="versesTabSearchButton" TargetType="Button">

<Setter Property="Width" Value="24" />
<Setter Property="Height" Value="22" />
<Setter Property="Foreground" Value="#1C1E2F" />
<Setter Property="BorderThickness" Value="0,0,0,0" />
<Setter Property="BorderBrush" Value="{x:Null}" />
<Setter Property="Background" Value="{x:Null}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Width="24" Height="22">
<Icon:PackIconOcticons x:Name="searchIcon" Kind="Search" Width="16" Height="16" Foreground="{TemplateBinding Foreground}" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>

<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="Green" />
<Setter Property="Cursor" Value="Hand" />
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="versesTabSearchButton" TargetType="Button">

<Setter Property="Width" Value="24" />
<Setter Property="Height" Value="22" />
<Setter Property="Foreground" Value="#1C1E2F" />
<Setter Property="BorderThickness" Value="0,0,0,0" />
<Setter Property="BorderBrush" Value="{x:Null}" />
<Setter Property="Background" Value="{x:Null}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Width="24" Height="22">
<Icon:PackIconOcticons x:Name="searchIcon" Kind="Search" Width="16" Height="16" Foreground="{TemplateBinding Foreground}" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>

<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="Green" />
<Setter Property="Cursor" Value="Hand" />
</Trigger>
</Style.Triggers>
</Style>
I want the icon to change color when it comes to the button area, but it changes when the mouse comes to the icon. Use metro.mahapps.ıcon nuget pack
6 Replies
Cutter
Cutter2y ago
What do you mean when it comes to the button area?
frknztrk
frknztrk2y ago
I want the icon to change color when I enter the blue area, but it changes when I hover over the icon.
Cutter
Cutter2y ago
Does it only click when you hover the icon itself also or can you click in the area too? @frknztrk
frknztrk
frknztrk2y ago
no it doesn't trigger the click event
Cutter
Cutter2y ago
so you must click the icon itself to trigger or you just wanting to hover for now?
frknztrk
frknztrk2y ago
It changes color to show that it is clickable when hovering over it, but it is not very efficient when it comes to the icon. I want to show it when I approach that area.