Search code examples
c#wpfdatatrigger

Multiple Value Conditions for DataTrigger


I have a trigger list

<Style.Triggers>
    <DataTrigger Binding="{Binding Path=AddServerPanelVisible}" Value="True">
        <DataTrigger.EnterActions>
            <BeginStoryboard>
                <Storyboard>
                    <!-- Stuff -->
                </Storyboard>
            </BeginStoryboard>
        </DataTrigger.EnterActions>
    </DataTrigger>
    <DataTrigger Binding="{Binding Path=AddServerPanelVisible}" Value="False">
        <DataTrigger.EnterActions>
            <BeginStoryboard>
                <Storyboard>
                    <!-- Stuff -->
                </Storyboard>
            </BeginStoryboard>
        </DataTrigger.EnterActions>
    </DataTrigger>
</Style.Triggers>

But this isn't working. How could I take the same DataTrigger with different values? I want to have a different Storyboard for the True condition than for the False condition.


Solution

  • Use the DataTrigger.EnterActions to trigger an animation when the bound value becomes true. Use DataTrigger.ExitActions to trigger another animation when the bound value becomes false.