This allows for easy scalability without loss of quality. wpf provides a choice of two methods of rendering. This Drawing objects and the Shape. Shape objects represented by a set of primitives Rectangle, Ellipse, etc. And it's easy can be used directly in the markup xaml, maintain alignment and processing of events, but the system performance when rendering a sufficiently large number of such facilities is poor. DrawingVisual objects provide maximum performance when drawing shapes, images or text. This is achieved by ensuring that they do not support the layout and events. Moreover, they can not be described in the markup.

For their use, you must create a container, inherited from FrameworkElement. For storing objects DrawingVisual need to use class VisualCollection. To ensure the layout of the container, cover two simple functions. public class BaseRenderer: FrameworkElement / / member for optimize protected you must use the Add and add the objects sequentially. Otherwise, for example when using the Insert by counting the visual parent for all elements with index greater than the insertion index.

Analoichnym behaves function Remove. Therefore it is better to clear the collection entirely. This is easily seen using any profiler, for example jetBrance 5 or by looking the source code, for example, using Reflector 6. So, initially created object MapDrawingVisual, which is the successor object DrawingVisual and has a link to a business object map, to perform the procedure HitTesting (hit test). Then get the style to draw the object, the geometry is created and made herself provides the best performance.

Sorry, comments are closed.