Compartilhar via


Editar contexto arquitetura

This topic explains the role of the editing context when you develop feature providers and feature connectors for the WPF Designer for Visual Studio. For more information about feature providers and feature connectors, see Recurso provedores e conectores de recursos.

O contexto de edição: Captura o estado atual do 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 Como: Criar um Conector de Recursos Personalizado.

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 Comparando o Framework Windows Forms Designer para o framework Designer WPF.

Consulte também

Referência

Microsoft.Windows.Design.Services

EditingContext

ContextItem

Outros recursos

Extensibilidade do WPF Designer