get
get

Reputation: 21

WPF container that allows objects to move around

I worked a litte with WPF but it used copy-paste for XAML and mostly C# coding for the background logic. Now I want to start a project with a friend and use WPF because it will be a GUI intensive one.

Question:

In our app, we want to have a surface on which we can put objects and the user should be able to move the objects around. This should be 2D. By moving, I mean click on an object and drag it around inside the surface. In the end, I think the movement should be only in one direction ( only horizontal), but for the moment it should be possible to move them in any direction. The only restriction that should apply is that they can't remain one on top of the other.

Can you give me any hints on what container should we use for the surface, what base class should we use for the objects moving in the container? Or does WPF have something that works out of the box for this case? General hints how we should start this would be appreciated.

I know that this is a lot for some one that doesn't have so much experience with WPF but I did the same thing when I came from C++ to C# and it worked :).

Upvotes: 2

Views: 5612

Answers (3)

Tormod
Tormod

Reputation: 4573

This is a blogpost from version .NET 3.5 http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/05/08/test-post-1.aspx

"Dragable" is a common case when discussing the topic of behavior in expression blend.

Upvotes: 1

Cameron MacFarland
Cameron MacFarland

Reputation: 71856

Have a look at this article on CodeProject:

WPF Diagram Designer: Part 1

It uses a Canvas to display items, and implements code to allow the items to be dragged around the Canvas.

Upvotes: 1

blindmeis
blindmeis

Reputation: 22435

Canvas is always a good container to move things around.

Upvotes: 2

Related Questions