chinh nguyen van
chinh nguyen van

Reputation: 889

How to dynamic add model to viewport when animation completed in WPF?

I am using StoryBoard to do animation in WPF and I use multiple DoubleAnimation in that StoryBoard. And I want to add some model when that DoubleAnimation is completed. I tried to use DoubleAnimation.Completed event but it only fired when the whole StoryBoard completed. How can I achieve that? Thanks

Upvotes: 1

Views: 638

Answers (1)

newb
newb

Reputation: 856

If you haven't yet, add to your view's code-behind:

using System.Windows.Media.Media3D;

Then add (assuming your Viewport3D is named "mainViewport":

void AddModel(GeometryModel3D mod)
{
    mainViewport.Children.Add(new ModelVisual3D() { Content = mod });
}

And call when you want to add a model.

Upvotes: 2

Related Questions