开发者

How to create an ownerdrawn control in silverlight 4?

Can't find a good explanation on how to create a simple ownerdrawn control in Silverlight.

Let's say I want to create an "Arch" or a "Line" control.

What should be my base class?

How do I get access to开发者_StackOverflow社区 the drawing context so my code can render the graphics?

I see that FrameworkElement in Silverlight doesn't provide much help here. What are the best practices?

Thanks

Update: The reason that I'm asking this is very simple - I'm building a virtual (unlimited) surface that can be scrolled in any direction that should show visualize a lot of data. Something like diagramming. I'm planning to start with something very simple that is similar to the Familiy.Show (http://familyshow.codeplex.com/). That diagram implementation is solely WPF and rendered solely through OnRender(DrawingContext) paradigm.

Thanks


The concept of a control taking responsibility for drawing pixels on the surface of a rectangle it owns is alien to Silverlight.

Since you include the term "best practice" I'm going to extrapolate heuristically that you want to build custom controls that generate their UI entirely from primitive operations.

Create a new "Custom Templated Control". In the ControlTemplate added to the "themes/generic.xaml" you can now include the Xaml that specifically describes UI you need.

Silverlight supports elements able to descibe fundemental components that derive from Shape such as an Elipse (which can also draw an arc), Line, Rectangle, Polygon and Polyline. A Path can also be used describe more complex shapes that may include Bezier segments.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜