R
R
Rogue3332016-10-25 12:51:35
.NET
Rogue333, 2016-10-25 12:51:35

Animation stops in XAML, what could be wrong?

Good afternoon.
There is a TabControl with multiple tabs and there are animations in the tabs.
When switching between tabs, the animation slows down, and then stops altogether.
What can be wrong?
If you do not switch between tabs, then everything is fine.

<Image.Triggers>
                <EventTrigger RoutedEvent="Image.Loaded">
                    <EventTrigger.Actions>
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)"
                                                 RepeatBehavior="Forever" DecelerationRatio="0"
                                                 AutoReverse="False" FrameworkElement.FlowDirection="RightToLeft">
                                    <EasingDoubleKeyFrame KeyTime="0:0:2.10" Value="0"></EasingDoubleKeyFrame>
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>
            </Image.Triggers>
            <Image.RenderTransform>
                <TransformGroup>
                    <ScaleTransform/>
                    <SkewTransform/>
                    <RotateTransform Angle="{Binding Speed, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                    <TranslateTransform/>
                </TransformGroup>
            </Image.RenderTransform>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rogue333, 2016-10-26
@Rogue333

<UserControl.Resources>

        <Storyboard x:Key="keyfanStoryboard">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)"
                                                 RepeatBehavior="Forever" DecelerationRatio="0"
                                                 AutoReverse="False">
                <EasingDoubleKeyFrame KeyTime="0:0:3.10" Value="360"></EasingDoubleKeyFrame>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        
    </UserControl.Resources>

private Storyboard board = null;
---
        InitializeComponent();
        board = (Storyboard)this.FindResource("keyfanStoryboard");
        board.Begin(Animation);
---
        board.Resume();
---
        board.Pause();

V
Vyacheslav Zolotov, 2016-10-25
@SZolotov

UI thread can be loaded?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question