The CanvasControl is a custom WPF control that can be used to efficiently display all kinds of data.

Namespace: yWorks.Canvas
Assembly: yWorks.yFilesSilverlight.Viewer (in yWorks.yFilesSilverlight.Viewer.dll) Version: 2.4.0.0

Syntax

C#
[TemplatePartAttribute(Name = "PART_ContentHost", Type = typeof(CanvasContentHost))] public class CanvasControl : Control, ILookup
Visual Basic
<TemplatePartAttribute(Name := "PART_ContentHost", Type := GetType(CanvasContentHost))> _ Public Class CanvasControl _ Inherits Control _ Implements ILookup

Remarks

The control supports high performance zooming and panning of visual content and provides a high level view of the visual tree. The control uses double precision world-coordinates to render items that are composed using a visual tree. In its most simple form the scene graph is a tree like structure of elements that will be rendered in depth-first-search order just like the visual tree WPF uses.

The scene graph tree is made up of ICanvasObject elements. Multiple elements are grouped in ICanvasObjectGroup elements. An ICanvasObject consists of a user-object and an ICanvasObjectDescriptor that is used by the rendering engine to query interfaces that perform the actual creation of the FrameworkElements, hit testing, and bounds calculation.

This control offers convenience methods to Print()()()() the contents.

This control supports the WPF templating mechanism. Template authors need to include a named template part of type CanvasContentHost named PART_ContentHost that will be used to host the actual contents.

This control comes with a number of default command bindings that work on the view port:

The handlers for IncreaseZoom and DecreaseZoom use the specified command parameter as the factor by which the Zoom value is multiplied or divided, respectively. The parameter is not required. If it is not present a default value is used. The handler for the Zoom command needs a parameter. The parameter can either be a number which is interpreted as the new zoom level, or it can be a suitable object. Supported objects are RectD, Rect, PointD, Point and ILookup. If a rectangle is specified as the parameter for the Zoom command, the handler adjusts the Viewport such that the rectangle tightly fits into it. If a point is specified, the handler sets the Center to that point. If the parameter implements ILookup, then the handler tries to get a IBoundsProvider from the lookup and uses the bounds obtained from the bounds provider as the rectangle to zoom to.

Also, Print is supported out of the box.

In addition to the bindings for existing commands this class declares a new RoutedUICommand, FitContentCommand, that will invoke the FitContent()()()() method.

All commands can be removed from the CommandBindings if desired.

Related Reading in the Developer's Guide

CanvasControl is discussed in detail in the section Class CanvasControl.

Related Demo Applications

See the yFiles for Silverlight tutorials for step by step introductions.

Inheritance Hierarchy

System..::..Object
  System.Windows..::..DependencyObject
    System.Windows..::..UIElement
      System.Windows..::..FrameworkElement
        System.Windows.Controls..::..Control
          yWorks.Canvas..::..CanvasControl
            yWorks.yFiles.UI..::..GraphControl
            yWorks.yFiles.UI..::..GraphOverviewControl

See Also