C#C
C#4y ago
9 replies
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>


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
Was this page helpful?