views:

336

answers:

0

This style correctly fades my toolbar in or out based on the changing of a ViewModel Property:

<Style x:Key="PageToolBarStyle" TargetType="Border">
    <Style.Triggers>
        <DataTrigger Binding="{Binding PageToolBarVisible}" Value="true">

            <DataTrigger.EnterActions>
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation
                            Storyboard.TargetProperty="Opacity"
                            From="0.0" 
                            To="1.0" 
                            Duration="0:0:2"/>
                    </Storyboard>
                </BeginStoryboard>
            </DataTrigger.EnterActions>

            <DataTrigger.ExitActions>
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation
                            Storyboard.TargetProperty="Opacity"
                            From="1.0" 
                            To="0.0" 
                            Duration="0:0:2"/>
                    </Storyboard>
                </BeginStoryboard>
            </DataTrigger.ExitActions>

        </DataTrigger>

        <Trigger Property="Opacity" Value="0">
            <Setter Property="Visibility" Value="Collapsed"/>
        </Trigger>

    </Style.Triggers>
</Style>

However, when the application loads the status of the toolbar (faded out or in) is not in sync with the value of the ViewModel property (true or false). So I want to force this style to be executed upon loading the window, what is the syntax to do this, here is pseudo code of what I want to do:

<Window.Triggers>
    <EventTrigger RoutedEvent="FrameworkElement.Loaded">
        <EventTrigger.Actions>

           <!-- PSEUDO-CODE: -->
            <ExecuteTriggerStyle StyleToExecute="{StaticResource PageToolBarStyle}"/>

        </EventTrigger.Actions>
    </EventTrigger>
</Window.Triggers>