Reputation: 919
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>
Upvotes: 0
Views: 365
Reputation: 200
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 DoubleAnimation
s. 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.
Upvotes: 2