views:

46

answers:

2

I need to build a specific interactive drawing "canvas".

In that canvas, user will be able to place graphic elements - points linked with lines.

I have a ready WinForms UserControl - pointsList that represents the list of points presents in the canvas. PointsList is able to add and remove points, link them with a line.

pointsList should be a floating(movable) and resizeable control in the canvas(like a windows on a screen).

My questions:

  1. What is the best choice for this "canvas" - a WPF UserControl or CustomControl?
  2. Is it possible to place a (floating) WinForm UserControl inside a WPF control?
  3. Will it be hard to rewrite a floatting and resizeable WPF user control inside an other?

EDIT

Better explanation of the "Floating Control":

Imagine a WPF Container (say, a Canvas). In this canvas you have a button. When you click the button, a "Floating Window Control" opens inside the Canvas.

This control is like a Windows Form, can be opened, moved, closed, resized, but all this inside the parent canvas. Something similar to a MDI parent and child forms, but the parent is not a form, but a WPF container (say Canvas).

+3  A: 

1) Both types will suit your needs. UserControls are typically easier to author, especially when you are new to WPF. CustomControl is actually not a class, but it means that you extend an existing control. There are some differences between the 2 approaches, the biggest one is that a custom control is easier to make it themeable. In your case, I assume this is not a need, so I'd recommend a UserControl. More info on this: http://www.wpftutorial.net/CustomVsUserControl.html

2) Yes. You can put a WinForms control inside WPF using the WindowsFormsHost control. One limitation is that the WinForms control must be a non-transparent rectangle, meaning you cannot throw in different shapes and expect them to overlay correctly. Look for WindowsFormsHost and you'll find lots of examples.

3) Can you explain better? don't understand what you mean, but of course you can place UserControls within each other, and WPF is especially useful when dealing with dynamic sizing.

Julian Dominguez
thanks. 1) Will use the UserControl for canvas, 2)I don't need transparency, but interaction (dragging, by e.g.); 3) see my edit for the 3rd point.
serhio
Julian Dominguez
3) Regarding the MDI kind of UI, this can definitely be done. Look in google for examples, but rest assured that WPF will allow it, with less or more effort depending on your scenario.
Julian Dominguez
+1  A: 

We got a lot of mileage adapting this WPF code from CodeProject. link text

jeff
if so, what will be your recommendation?
serhio