Everyone, I tried to scale button's size, code works fine, if I click only once, but if I click multiple times the button in a row, button can't return its original size. Here is code:
private void ButtonSearchMedication_OnClick(object sender, RoutedEventArgs e)
{
//Assign variation of width in term of begin, end and duration
DoubleAnimation widthAnimation =new DoubleAnimation(ButtonSearchMedication.ActualWidth, ButtonSearchMedication.ActualWidth*0.8, new Duration(timeSpan:TimeSpan.FromSeconds(0.2)) );
//Assign variation of height in term of begin, end and duration
DoubleAnimation heightAnimation = new DoubleAnimation(ButtonSearchMedication.ActualHeight,ButtonSearchMedication.ActualHeight*0.8, new Duration(timeSpan:TimeSpan.FromSeconds(0.2)));
//Assign properties to button
ButtonSearchMedication.BeginAnimation(Button.WidthProperty,widthAnimation);
ButtonSearchMedication.BeginAnimation(Button.HeightProperty,heightAnimation);
}
private void ButtonSearchMedication_OnMouseLeave(object sender, MouseEventArgs e) {
DoubleAnimation widthAnimation = new DoubleAnimation(ButtonSearchMedication.ActualWidth, ButtonSearchMedication.ActualWidth*1.25,new Duration(timeSpan:TimeSpan.FromSeconds(0.2)));
DoubleAnimation heightAnimation = new DoubleAnimation(ButtonSearchMedication.ActualHeight, ButtonSearchMedication.ActualHeight*1.25,new Duration(timeSpan:TimeSpan.FromSeconds(0.2)));
ButtonSearchMedication.BeginAnimation(Button.WidthProperty,widthAnimation);
ButtonSearchMedication.BeginAnimation(Button.HeightProperty,heightAnimation);
}
Is there anything I can do to make sure the size of button become its original size after every MouseLeave? Thanks