Load Transition/Animation

5 posts, 1 answers
  1. The Cowboy
    The Cowboy avatar
    19 posts
    Member since:
    Mar 2010

    Posted 04 May 2012 Link to this post

    Do you have an sample for applying a transition when loading  a diagram.  For example, if I have an existing diagram and want to fade or zoom to a new diagram when I issue the Load() command?
  2. Answer
    Francois Vanderseypen
    Francois Vanderseypen avatar
    46 posts
    Member since:
    Oct 2009

    Posted 04 May 2012 Link to this post

    There are various ways to achieve this. For example;

    // somewhere in the constructor, for example
    diagram.ItemsChanged += DiagramOnItemsChanged;
      
      
    private void DiagramOnItemsChanged(object sender, DiagramItemsChangedEventArgs e)
    {
        if (e.NewItems.OfType<IDiagramItem>().Any())
        {
            foreach (var item in e.NewItems.OfType<IDiagramItem>())
            {
                var fa = new DoubleAnimation { Duration = TimeSpan.FromSeconds(5), From = 0d, To = 1d, EasingFunction = new CubicEase() };
                var sb = new Storyboard();
                sb.Children.Add(fa);
                Storyboard.SetTarget(fa, item as DependencyObject);
                Storyboard.SetTargetProperty(fa, new PropertyPath("Opacity"));
                sb.Begin();
            }
      
        }
    }


    Hope this helps, Fr.
  3. UI for WPF is Visual Studio 2017 Ready
  4. The Cowboy
    The Cowboy avatar
    19 posts
    Member since:
    Mar 2010

    Posted 05 May 2012 Link to this post

    Good idea.

    I also though about have a second RadDiagram, loading what I want in there, and then animating the active one out and the new one in.
  5. Hristo
    Admin
    Hristo avatar
    352 posts

    Posted 08 May 2012 Link to this post

    Hi,

    Having two diagrams would have affect over the performance though. That's why I personally prefer Francois approach, which is simple and cohesive.
    However, the way you should implement it depends what fits best in your case.

    All the best,
    Hristo
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  6. The Cowboy
    The Cowboy avatar
    19 posts
    Member since:
    Mar 2010

    Posted 09 May 2012 Link to this post

    Thanks for all the suggestions, but I simply used the RadTransitionControl. Works like a charm.
Back to Top
UI for WPF is Visual Studio 2017 Ready