WPF: pure XAML when lunch Storyboard base of binding condition

So i have this Storyboard:

<Storyboard x:Key="animate">
            <DoubleAnimation BeginTime="0:0:0" Storyboard.TargetProperty="Opacity" From="1" To="0" Duration="0:0:2.0"/>

My binding value:

public bool IsFound
    get { return _isFound; }
        _isFound= value;

And my Grid that get this Storyboard:

<Grid name="myGrid">

    Storyboard storyboard = Resources["animate"] as Storyboard;
        if (storyboard != null)

So i am looking for something pure XAML instead of checking this IsFound in code behind.

1 answer

  • answered 2018-07-11 03:33 Mark Feldman

    You can use a DataTrigger:

    <Style TargetType="Grid" x:Key="MyAnimatedGrid">
            <DataTrigger Binding="{Binding IsFound}" Value="True">
                    <BeginStoryboard StoryBoard="{StaticResource animate}" />