views:

61

answers:

0

I have a data model that represents segments of a curve that looks like this:

Envelope curve

The fields are x and y coordinates of the anchor points (red), and a slope value represented by the control points (green). For the curve to be editable by the user, I'm thinking of using Thumb objects for both anchor and control points.

Since I also would like to be able to present the user with an interface where it is possible to enter coordinates into text boxes, I'm thinking of implementing this curve editor as a lookless control. The problem I face is to find the best way to organise the elements. Some thoughts on what I could do:

  1. Add the data model view objects to an ItemsContainer with a custom ItemsPanel and a DataTemplate that creates one anchor point and one control point for each data model object. This causes two and two points to be wrapped in a ContentPresenter which makes the interaction between the custom panel and the thumb points difficult.
  2. Use two different data model view objects, one for anchor points and one for control points, and a DataTemplateSelector to select the right DataTemplate. While there still is a ContentPresenter between the item and the panel (is it possible to avoid this?), interaction may be easier when there is only one item in the ContentPresenter.
  3. Don't use ItemsContainer at all, instead add the Thumb objects directly to the visual and logical trees of the custom panel. Of course I loose a lot of flexibility when it comes to the look and feel of the Thumb objects when they are not specified by templates. Maybe it's possible to duplicate this functionality from ItemsContainer so my control can have separate DataTemplates for the anchor and control points. The Thumb objects could then be added directly to the panel without ContentPresenters.

What's the most reasonable way to do this? Are there other alternatives than the ones I've thought of?