This is a migrated thread and some comments may be shown as answers.

Load Transition/Animation

4 Answers 58 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
The Cowboy
Top achievements
Rank 1
The Cowboy asked on 04 May 2012, 01:14 PM
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?

4 Answers, 1 is accepted

Sort by
0
Accepted
Francois Vanderseypen
Top achievements
Rank 2
answered on 04 May 2012, 02:15 PM
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.
0
The Cowboy
Top achievements
Rank 1
answered on 05 May 2012, 02:52 PM
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.
0
Hristo
Telerik team
answered on 08 May 2012, 07:09 AM
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 >>

0
The Cowboy
Top achievements
Rank 1
answered on 09 May 2012, 10:45 PM
Thanks for all the suggestions, but I simply used the RadTransitionControl. Works like a charm.
Tags
Diagram
Asked by
The Cowboy
Top achievements
Rank 1
Answers by
Francois Vanderseypen
Top achievements
Rank 2
The Cowboy
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or