October 03, 2006

WPF Base Classes

The base element classes are required to create custom class. Following figure shows various base classes which can be derived in the custom class.





DependencyObject Class

  • Represents an object that participates in the dependency property system.
  • Enables Windows Presentation Foundation (WPF) property system services on its many derived classes.
  • The property system's primary function is to compute the values of properties, and to provide system notification about values that have changed.
  • Classes inherited from DependencyProperty can use dependency properties.

Visual Class

  • Provides services and properties that are common to all visual objects.
  • The Visual object is a core WPF object, whose primary role is to provide rendering support. User interface controls, such as Button and TextBox, derive from the Visual class, and use it for persisting their rendering data.
  • The Visual object provides support for:
    • Output display: Rendering the persisted, serialized drawing content of a visual.
    • Transformations: Performing transformations on a visual.
    • Clipping: Providing clipping region support for a visual.
    • Hit testing: Determining whether a coordinate or geometry is contained within the bounds of a visual.
    • Bounding box calculations: Determining the bounding rectangle of a visual.
  • However, the Visual object does not include support for non-rendering features, such as:
    • Event handling
    • Layout
    • Styles
    • Data binding
    • Globalization

DrawingVisual Class

  • The DrawingVisual is a lightweight drawing class that is used to render shapes, images, or text.
  • It does not provide layout or event handling
  • In order to use DrawingVisual objects, you need to create a host container for the objects. The host container object must be derived
  • From the FrameworkElement class, which provides the layout and event handling support that the DrawingVisual class lacks support.

Viewport3DVisual Class

  • Provides a bridge between 2D Visual and Visual3D objects.
  • The Visual3D class is the base class for all 3D visual elements.

ContainerVisual Class

  • The ContainerVisual class is used as a container for a collection of Visual objects.
  • The DrawingVisual class derives from the ContainerVisual class, allowing it to contain a collection of visual objects.

ContentElement Class

  • Provides a WPF core-level base class for content elements.
  • Content elements are designed for flow-style presentation, using an intuitive markup-oriented layout model and a deliberately simple object model.

FrameworkContentElement Class

  • WPF framework-level implementation of the ContentElement base class.
  • Adds support for additional input APIs (including tooltips and context menus), storyboards, data context for databinding, styles support, and logical tree helper APIs.

Freezable Class

  • Defines an object that has a modifiable and a read-only (frozen) state.
  • Classes that derive from Freezable provide detailed change notification, can be made immutable, and can clone themselves.