I have a simple Border
element in my view with a child TextBlock
that is bound to a string that represents the status of a process in my application.
I am trying to animate this border so that it slides in to view from off-screen when the string that the TextBlock
is bound to is modified.
Here is what I have so far:
<Border>
<Border.Triggers>
<EventTrigger RoutedEvent="Binding.TargetUpdated">
<BeginStoryboard>
<Storyboard>
<ThicknessAnimation Storyboard.TargetProperty="Margin" From="0,-100,0,0" To="0,0,0,0" DecelerationRatio=".9" Duration="0:0:1" />
<ThicknessAnimation Storyboard.TargetProperty="Margin" From="0,0,0,0" To="0,-100,0,0" AccelerationRatio=".9" BeginTime="0:0:5" Duration="0:0:1" />
</Storyboard>
</BeginStoryBoard>
</EventTrigger>
</Border.Triggers>
<TextBlock Text="{Binding StatusText, Mode=OneWay, NotifyOnTargetUpdated=True}"></TextBlock>
</Border>
This works as intended but there are two problems that I do not know how to solve:
- The animation starts over whenever the text changes I don't want this. What I DO want is for the 5 second wait before it slides away to be restarted instead. So if the text is being constantly updated then the panel should stay still until its been more than 5 seconds since the last update then slide back up.
- When the application starts the animation plays immediately. I'm guessing since the initial binding counts as an update. How can I stop this from happening?