0

I have got a hidden button and when if condition is true, the button is visible to the user. But I want to get user attention to the button so wanted to button to jump or flash on/off for few seconds.

I have seen a few examples but they all triggered by mouseover event. I tried to replace the event trigger with Data Trigger but didn't accept it.

Does anyone have a similar code or different idea of how to do it, please?

 <Button Visibility="{Binding IsVisibleBtnCopyFromPreviousPriceList}" x:Name="BtnCopyProducts" Click="BtnCopyProductsist_Click" Grid.Column="1" Grid.Row="17" Grid.ColumnSpan="9" FontSize="16" Margin="0"  Height="70" Width="70" Background="Transparent"  BorderBrush="Transparent" >
 <StackPanel>
       <Image Source="Images/File_copy_64.png" Width="56" Height="56" />
  </StackPanel>
</Button>
AliAzra
  • 889
  • 1
  • 9
  • 28
  • 3
    [**Maybe**](https://stackoverflow.com/questions/9257091/to-set-blinking-effect-on-button-in-xaml) of use and or help you get a head start? – Trevor Apr 18 '19 at 13:41

1 Answers1

2

Have you looked into animations? They are quite simple to make. I use the DoubleAnimation class to achieve something similar on one of my projects to display a message to the user for a few seconds that things are syncing in the background.

Here's how I do it:

First I create a Storyboard

Storyboard myStoryboard = new Storyboard();

Then I create a couple DoubleAnimations. One that stays solid for a few seconds and one that fades out over a couple seconds. Here's the fading one:

DoubleAnimation fadeAnim = new DoubleAnimation();
fadeAnim.From = 1.0;
fadeAnim.To = 0.0;
fadeAnim.BeginTime = new TimeSpan(0, 0, 3);
fadeAnim.Duration = new Duration(TimeSpan.FromSeconds(2));

Finally the animations get added to the Storyboard:

myStoryboard.Children.Add(fadeAnim);
Storyboard.SetTargetName(fadeAnim, WarningGrid.Name);
Storyboard.SetTargetProperty(fadeAnim, new PropertyPath(Rectangle.OpacityProperty));

And then it's just a matter of hitting play:

myStoryboard.Begin(this);

While my example is a little bit different than what you are trying to accomplish, you might be able to use it to make a nice smooth and fast pulse with a few of these put together and set real fast.

Joshua Stevens
  • 200
  • 1
  • 9
  • 1
    Hi & welcome to SO. Perhaps you could improve your answer by giving a specific example of how an animation could help in this case? Otherwise, perhaps a comment would be more appropriate to get more infromation from the OP. – ardila Apr 18 '19 at 14:52