1

In Windows Phone 7 Silverlight, is there a way to design a custom control from scratch - i. e. with custom drawing and custom touch processing? What do I subclass for that?

2 Answers 2

7

Yes you can. You usually subclass Control, ItemsControl, or ContentControl. Here is a blog post that explains the process in detail: Creating a WP7 Custom Control in 7 Steps

2
  • Neither drawing nor touch processing in that example... Just a combination of primitives. Commented Mar 9, 2011 at 2:02
  • I'm not sure what you mean by drawing, almost all controls are simply collections of primitives built into a more interesting control. In terms of touch processing the Control class has the Manipulation events for you to hook into touch events. Commented Mar 9, 2011 at 2:34
1

As mentioned, you can create a custom control from scratch by deriving from the Control class. To implement gesture handling you can use the GestureService from the Silverlight Toolkit for WIndows Phone 7 or you can directly handle the ManipulationStarted, ManipulationDelta, and ManipulationCompleted UIElement events.

Jeff Prosise has a great series of four posts that cover touch manipulation in great detail:

For the "custom drawing" part, what did you have in mind? If a control built up from primitives isn't what you had in mind, what about lines and shapes?

1
  • Lines and shapes on the XAML level... An old joke about XML comes to mind. Here goes: <bitmap><row><pixel red="100" blue="200" green="0"/></row></bitmap> Commented Mar 9, 2011 at 15:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.