GetCurrentState on a storyboard defined and running in XAML

I searched everything and can not find the answer to this question. My application lives in a world of free XAML, so I have to rely on XamlReaders and the tree to find the elements. I have a component that handles the rendering of these XAML pages. This renderer must know the status of the storyboard, which can run on loaded XAML. So, what I would like to do in my renderer is something like this: -

var resources = _currentScreenFrameworkElement.Resources;
foreach (var item in resources.Values)
{
    if (item is Storyboard)
    {
        try
        {
            var storyboard = item as Storyboard;
            **if (storyboard.GetCurrentState() == ClockState.Active)**

All is well and good. However, the problem is that when I try to execute dcheck, CurrentState throws an exception: -

"Cannot perform action because the specified Storyboard was not applied to this object for interactive control."

Looking around, I see this because I need to make a guided storyboard. So my question is: how to do this in XAML? I do not run the storyboard in the code, so I can not go to the overloaded BeginStoryboard.

+5
1

, , .

, Controllable. Controllable, Begin.

, , IsControllable ( ).

BeginAnimation Xaml, 2 .

  • Name BeginAnimation. : " BeginStoryboard , "
  • , , BeginStoryboard.

, 1 ( )

<Button Name="btn1" Content="bla">
  <Button.Triggers>
    <EventTrigger RoutedEvent="Button.Click">
      <BeginStoryboard 
             Name="bnt1_beginStoryboard" 
             Storyboard={StaticResource someSharedStoryboard}"/>
    </EventTrigger>
  </Button.Triggers>
</Button>

2. , .. . , startStoryboard ( )

//The main point here is that we're passing in btn1
bnt1_beginStoryboard.Storyboard.Stop(btn1);
bnt1_beginStoryboard.Storyboard.SkipToFill(btn1);
bnt1_beginStoryboard.Storyboard.Resume(btn1);

"" , , :

+5

All Articles