Reputation: 793
It's possible to change the image source of a button control on mouseover?
If it's how it's done?
Upvotes: 1
Views: 1517
Reputation: 1826
You can use Trigger for this. You may follow this or this article for the solution
ref:
<!-- Button will change from Blue to Yellow on MouseOver -->
<Style TargetType="{x:Type Button}">
<Setter Property="Background" Value="Blue" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Yellow" />
</Trigger>
</Style.Triggers>
</Style>
Upvotes: 3
Reputation: 1026
Following code might help:
button1.MouseEnter += new MouseEventHandler(button1_MouseEnter);
button1.MouseLeave += new MouseEventHandler(button1_MouseLeave);
void button1_MouseEnter(object sender, MouseEventArgs e)
{
button1.Content = image1;
//do something
}
void button1_MouseLeave(object sender, MouseEventArgs e)
{
//do something
}
Upvotes: 4