Page 1 of 1

Storyboard c++

Posted: 21 Apr 2021, 10:37
by BartekW
Hey, how can I have control of storyboard C++? Can I have any callbacks methods when finished? Or started?

Re: Storyboard c++

Posted: 21 Apr 2021, 11:54
by sfernandez
You can register to the Completed event of the Storyboard:
Storyboard* storyboard = FindResource<Storyboard*>("SomeAnimation");
storyboard->Completed() += [](BaseComponent*, const TimelineEventArgs&)
{
  // do something
};
storyboard->Begin(this);

Re: Storyboard c++

Posted: 21 Apr 2021, 13:09
by BartekW
Ok thanks its what I needed exactly, but now I have some WPF question.
<Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                                            <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)">
                                            <EasingDoubleKeyFrame KeyTime="0" Value="-400"/>
                                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="300"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
Why does that code not moving my object? Its change its opacity but doesnt move :/

Re: Storyboard c++

Posted: 21 Apr 2021, 13:16
by sfernandez
Probably because your object doesn't have a TranslateTransform set in its RenderTransform property.
<Rectangle>
  <Rectangle.RenderTransform>
    <TranslateTransform/>
  </Rectangle.RenderTransform>
</Rectangle>

Re: Storyboard c++

Posted: 21 Apr 2021, 13:30
by BartekW
Probably because your object doesn't have a TranslateTransform set in its RenderTransform property.
<Rectangle>
  <Rectangle.RenderTransform>
    <TranslateTransform/>
  </Rectangle.RenderTransform>
</Rectangle>
Yes, thats was it! I tested it on something other Thanks

Re: Storyboard c++

Posted: 21 Apr 2021, 14:13
by sfernandez
Great, marking this as solved.