0

I have this XAML:

<Style.Triggers>
    <DataTrigger Binding="..." Value="True">
        <DataTrigger.EnterActions>
            <BeginStoryboard Name="ToTrue">
                ...
            </BeginStoryboard>
        </DataTrigger.EnterActions>
        <DataTrigger.ExitActions>
            <BeginStoryboard Name="ToFalse">
                ...
            </BeginStoryboard>
        </DataTrigger.ExitActions>
    </DataTrigger>
    <EventTrigger RoutedEvent="Loaded">
        <SkipStoryboardToFill BeginStoryboardName="ToTrue"/>
        <SkipStoryboardToFill BeginStoryboardName="ToFalse"/>
    </EventTrigger>
</Style.Triggers>

As you can see, I am using SkipStoryboardToFill to ensure that when the control first loads it doesn't bother playing the transition storyboards.

This works. However, it spams the console with warnings (since only one of the storyboards will be active) and isn't elegant at all.

Is there a "correct" way of skipping all active storyboards on an element that I'm not seeing?

There is no code-behind to work with here.

Artfunkel
  • 1,832
  • 17
  • 23

1 Answers1

1

Why not implement this as a state transition with VisualStateManager rather than data triggers on a style definition

Dean Chalk
  • 20,076
  • 6
  • 59
  • 90
  • Because there is no code-behind to trigger the transitions. – Artfunkel Mar 24 '14 at 15:55
  • you dont need code-behind to trigger transitions http://stackoverflow.com/questions/6862332/start-a-visualstate-transition-from-xaml – Dean Chalk Mar 24 '14 at 17:11
  • Unfortunately I can't use Blend things in my target environment. Ugh, why didn't Microsoft just make all that stuff the standard? – Artfunkel Mar 24 '14 at 17:12
  • Well you could create an attached property to do the same :) – Dean Chalk Mar 24 '14 at 17:14
  • or you could get System.Interactivity from nuget then write your own behaviir (very easy) – Dean Chalk Mar 24 '14 at 17:17
  • The nuget package is interesting, but I doubt it will be compatibly with [the non-Microsoft runtime](http://www.noesisengine.com/noesis_gui_features.htm) I'm using. I'll look into an attached property though - that might just do the trick. :) – Artfunkel Mar 24 '14 at 19:42
  • Turns out you can't add attached props to a ControlTemplate. I hacked around that by accessing the `TemplatedParent` of the template's root control but it seems that my `Loaded` event handler fires too soon - strange, considering that the same event is handled correctly by the EventTrigger. I've spent far too long on this "problem" given that what I have already works...thanks for your efforts though, Dean! – Artfunkel Mar 24 '14 at 21:16