Reputation: 4302
I kind of want to make a game.... so I want able to dynamically to add a data object to the Canvas and is dispaly it.
i.e) 1) a Car object, contains the car information, when it binds to the Canvas, I want to display it as a UserControl (contains some graphic).
2) When the car object display display/add/remove to the Canvas, it should do some animation.
So there is 3 questions:
Some suggestion will be appreciated :)
Upvotes: 1
Views: 2000
Reputation: 4363
I assume you want multiple objects on your canvas. To do so you need to template an ItemsControl. Template the panel to be a canvas. This is all done in the presentation layer with XAML. Then bind your ItemsControl's ItemsSource to the collection in your view model.
Upvotes: 1
Reputation: 184376
To display animations when the items are added to a panel you can use Fluid Layout from the Blend SDK. (Some demonstration video; sadly doesn't show the generated code for those without Blend)
For methods to bind to a canvas see this question.
I would not recommend doing this imperatively.
Upvotes: 1