Editing Context Architecture
This topic explains the role of the editing context when you develop feature providers and feature connectors for the Windows Presentation Foundation (WPF) Designer for Visual Studio. For more information about feature providers and feature connectors, see Feature Providers and Feature Connectors.
The Editing Context: Capturing the Current State of the Designer
A visual designer accumulates a significant amount of state information as it is being used. State can represent any kind of design-time information, such as objects in the current selection or the behavior when the mouse button is clicked. State must be stored in a central location so that it can be retrieved when it is needed. The EditingContext class represents the central state repository for the designer.
Services
A service is a single instance of a class, which defines a well-described behavior. A service provides behavior and implementation in the designer. Once a service is created in a context, it is always present until the context is disposed. Services never disappear from the context. Services have consistent instance values, so it is always safe to cache them. For a code example that shows how to implement a service, see How to: Create a Custom Feature Connector.
Context items
A context item is an immutable object and contains state. Some context items also define methods, which can perform operations on the state they contain.
A context item may be added to and removed from a context. Context items are transient, but they always have a value. Even if a particular context item is not in the context, it has a default value and never returns null.
Unlike a service, the value of a context item can change at any time, so you should never cache a context item. You can subscribe to a change callback, which is raised when a particular type of context item changes.
Context items are immutable, but new context items can replace existing context items to simulate mutability.
Subscriptions
Services and context items have managers. Service managers and context item managers are essentially tables, which hold data. For example, you use the service manager to publish new services.
Service managers and context item managers also provide a subscription mechanism, which notifies code when a particular piece of data is present. This notification is implemented as a callback delegate. A subscription is a delegate that is called when a particular service or context item type has been added.
Similarity to the ComponentModel Designer Framework
The editing context is conceptually similar to the IDesignerHost and IServiceContainer interfaces in the System.ComponentModel.Design namespace. For more information, see Comparing the Windows Forms Designer Framework to the WPF Designer Framework.
See Also
Reference
Microsoft.Windows.Design.Services