Norbert Forgacs
Norbert Forgacs

Reputation: 593

WPF how to make button icon spin only when mouse over

I am using mahapps iconpacks and I come across this method "spin" but I have no idea how to bind it to a mouse over event

 <Button x:Name="btnRefresh" 
 Content="{iconPacks:PackIconMaterial Kind=Refresh, Spin=True}">

I want the icon to spin only when the mouse cursor is over the button and stop from spinning when it's not. Thanks.

Upvotes: 0

Views: 757

Answers (1)

Norbert Forgacs
Norbert Forgacs

Reputation: 593

If anyone looks for an answer:

<Button x:Name="btnRefreshSpin" 
   Style="{DynamicResource MetroCircleButtonStyle}">
   <iconPacks:PackIconModern Kind="Refresh" Spin="{Binding Spin}" />
</Button>

and Spin is a simple method from the view model which returns true or false. A mouse over event can be linked to the same property

Upvotes: 1

Related Questions