In WPF toolkit datagrid I have a data trigger bound to opacity of cell element.
When UpVisibility
changes to 1 the path become visible and the animation starts to fade it to 0. Which works.
However my problem now - if I need to prematurely stop/cancel the fading and am setting UpVisibility
to 0 the Path is still visible and fading as nothing happened....
How to drop opacity to 0 instantly using MyValue object ?
<Path Data="M 5,0 0,10 10,10" Height="10" Width="10" Fill="Green" Opacity="{Binding MyValue[0].UpVisibility}" Margin="5,0,5,0">
<Path.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding MyValue[0].UpVisibility}" Value="1.0">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="1.0" To="0.0" Duration="0:0:10" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Path.Style>
</Path>
Storyboards can also be stopped using the ExitAction
on a DataTrigger
, which is called when the bound value changes out of the target state. Just give your BeginStoryboard
a name, and reference it in a StopStoryboard
action, like so:
<DataTrigger.EnterActions>
<BeginStoryboard Name="your_storyboard_name">
...
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<StopStoryboard BeginStoryboardName="your_storyboard_name" />
</DataTrigger.ExitActions>
This may be more appropriate than starting a second storyboard to stop or mask a different storyboard.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With