Compartilhar via


Arquitetura de extensibilidade Designer WPF

O WPF Designer for Visual Studio é um visual de edição de ambiente para WPF e Silverlight elementos. O WPF Designer se baseia em uma estrutura com uma arquitetura extensível, o qual você pode estender para criar sua própria experiência de design personalizado.

Estendendo o WPF Designer framework, você pode personalizar a aparência de tempo de design-e o comportamento do WPF e Silverlight conteúdo a um grau notável. For example, you can extend the WPF Designer in the following ways:

  • Customize move and resize glyphs with enhanced graphics.

  • Adicionar ummenu de atalhopara a superfície de design que altera o estado de um controle.

  • Modify the design-time appearance and behavior of a control across different tools.

O WPF Designer o poder expressivo completo do WPF e Silverlightoferece suporte a arquitetura. This enables the creation of many visual design experiences which were not previously possible.

Para obter um exemplo de como implementar uma experiência de tempo de design personalizado-para WPF e Visual Studio, consulte Walkthrough: Criando um adorno em tempo de design

Para o código de exemplo que mostra como design personalizado para criar experiências para WPF e Silverlight, consulte o Exemplos de extensibilidade doWPF Designer site.

WPF Designer de Framework

O WPF Designer framework é modular, o que significa que, quando você estende o tempo de design, você estender somente os elementos necessários para recursos. You do not have to write a lot of supporting code to enable your custom design features.

The object model consists of five functional units, which are described in the following table.

Functional unit

Description

Editing Model

Programming interface to objects in the designer.

Feature Providers

Main extensibility point in the designer framework.

Editing Context

Central store for a designer's state.

Commands, Tasks, and Tools

Comandos, tarefas e ferramentas para a entrada do processo usuário .

O tempo de-metadados de design

Assemblies que contêm o comportamento de tempo de design-de um controle, para separar fisicamente a lógica do designer de executar a lógica de tempo de-.

A ilustração a seguir mostra as unidades funcionais da WPF Designer framework.

Modelo de objeto de alto nível

Editing Model

The design environment interacts with run-time controls though a programming interface called an editing model. O modelo de edição consiste em três as subunidades de funcionais: um modelo, um wrapper pública que abstrai o modelo e um modo de exibição que representa o usuário interface (UI) do modelo.

The design environment uses the ModelItem type to communicate with the underlying model. All changes are made to the ModelItem wrappers, which affect the underlying model. This allows the model to be simple. The ModelItem wrappers handle complex designer features such as transaction support, undo tracking, and change notifications.

The ModelService class provides the entry point for the editing model and for global event notifications.

The ViewService class maps visual representations to the underlying model items.

Both services are required for the designer to function. The DesignerView class, which is responsible for processing user input and routing it to commands, requires both of these services to accurately map user input back to the model.

Feature Providers

You extend the design-time behavior of your types by using the FeatureProvider or the FeatureConnector<TFeatureProviderType> classes. The FeatureConnector<TFeatureProviderType> class manages a list of FeatureProvider objects.

The FeatureProvider class provides the most basic extensibility point. A feature provider is a lightweight feature or add-in which typically does not require much from the design environment and is created and destroyed in a given context. Features providers are used to add new bits of UI to the design surface or to modify some basic behavior. For example, a feature provider might add more grab handles or provide a new kind of mouse-drag behavior.

To access the deepest level of extensibility, derive from the FeatureConnector<TFeatureProviderType> class. This class exposes a service provider, through which derived feature connector classes can handle events and request and publish services. For example, you might implement a feature connector to provide selection UI or object-specific serialization.

In general, implement a feature to extend existing concepts. Implement a feature connector to provide new concepts. For more information, see Recurso provedores e conectores de recursos.

Editing Context

A significant amount of state information is accumulated in a running designer. For example, your designer's state might include which objects are selected, or the behavior that occurs when the left mouse button is pressed. Designer state is stored in a central location, so that it can be found when it is needed. The EditingContext class represents this central repository of state for the designer.

O deEditingContextclasse separa o estado em duas categorias: os dados e comportamento. Data is stored as a table of context items and behavior is stored as a table of services. Both tables are indexed by a type-based key and are enumerable.

The ContextItem class holds a single piece of state in the designer. Context items are immutable, but new context items can replace existing context items to simulate mutability.

Serviços são acessados através de Services propriedade, que retorna uma instância de ServiceManager, e itens de contexto são acessados por meio a Items propriedade, que retorna uma instância de ContextItemManager.

Commands, Tasks, and Tools

The WPF Designer tool architecture consists of commands, tasks, and tools. 

A command is a unique identifier that represents some behavior. Por exemplo, o Recortar é um comando que significa para recortar o texto atual e adicioná-lo na área de transferência. O código que implementa a Recortar varia de aplicativo para o aplicativoe até mesmo varia dentro de um aplicativo. For example, cutting text in a Word document is a different implementation than cutting text in the search text box of the same document. Independentemente da implementação, o comando Recortar permanece constante.

The WPF Designer augments the WPF command system by introducing a concept of a tool command. A tool command implements the ICommand interface and is like the RoutedCommand class.

A task has a collection of command bindings, which allows you to add routed commands. The DesignerView class has code which uses the same routing strategy as tool commands to find and execute routed commands that are defined on tasks. The DesignerView class enables tasks which support common WPF commands, such as Copy.

A tool is a class which processes user input. All user input comes into the designer as one or more input events. Those input events are passed to the currently active tool, which converts them to input bindings. If an input binding is returned, the command within the binding is executed.

A tool can represent the global mode of the designer. For example, if the user is selecting components on the design surface, that selection mode is possible because the currently active tool offers input bindings and commands that handle selection. When the user creates a new instance of a control, a different tool becomes active and offers a different set of commands, which are bound to the same input bindings.

O tempo de-metadados de design

No WPF Designer framework, definindo o tempo de design-o comportamento de um controle é especificado por atributos e fatorado um separado assemblyde metadados . Designers de diferentes podem consumir a assemblies diferentes de metadados com implementações de tempo de design completamente diferente-. This decouples the run-time and design-time behavior, so that you can revise the designer separately from the control.

Para especificar um assembly fornece o projeto-tempo de implementação, marcar o assembly com o ProvideMetadataAttribute e incluir uma classe que implementa o IProvideAttributeTable interface.

For more information, see Fornecimento de metadados de tempo de design.

O tempo de-suporte no Expression Blend de design

O WPF Designer oferece suporte a todos os recursos na estrutura de extensibilidade . Expression Blend suporta os seguintes recursos.

  • Adorners

  • Menus de contexto

  • DesignModeValueProvider

  • Inicializadores dePadrão

  • Tudo os ModelItem recursos, como a seleção e manipulação

  • janela Propriedades extensibilidade

Expression Blend não suporta ParentAdapter e PlacementAdapter.

WPF Designer Assemblies

O WPF Designer consiste em vários assemblies que pertence a uma das três categorias: público, privado e designer-específico.

The public assemblies expose classes which you can use to add design-time logic to your controls.

designere privado-conjuntos específicos definem o conjunto de recurso da WPF Designer e suas interações com designers, como Visual Studio e Expression Blend.

Os designers WPF e Silverlight são instalados como uma única entidade. Não é um pacote separado para cada designer.

The following table shows how WPF Designer features are deployed.

Assembly

Public API

Description

Microsoft.Windows.Design.Extensibility.dll

Yes

Fornece um modelo de extensibilidade por meio de atributos e lógica de integração do Visual Studio SDK.

Microsoft.Windows.Design.Interaction.dll

Yes

Provides user input and display classes.

Microsoft.Windows.Design.Markup.dll

No

Fornece mecanismos de modelo XAML e o documento.

Microsoft.VisualStudio.Xaml.dll

No

Fornece noções básicas de XAML para qualquer designer através de um serviço, um backplane de dados e manipulação de metadados.

Microsoft.Windows.Design.Host.dll

No

API particular para hospedagem um designer (específicas para Visual Studio).

Microsoft.Windows.Design.Developer.dll

No

WPF Designer implementation.

Microsoft.Windows.design.Developer.. Dll doWPF

No

Microsoft.Windows.design.Developer.. Dll doSilverlight

No

Microsoft.Windows.design.Platform.dll

No

Camada de plataforma com classes abstratas. Implementações de plataforma implementam classes abstratas neste assembly.

Microsoft.Windows.design.Platform.. Dll doWPF

No

Tempo de design específico--de plataforma para WPF.

Microsoft.Windows.design.Platform.. Dll doSilverlight

No

Tempo de design específico--de plataforma para o Silverlight.

Microsoft.Expression.DesignModel.dll

No

Tempo de- assemblyde design de Expression Blend.

Microsoft.Expression.Platform.. Dll doWPF

No

Tempo de- assemblyde design de Expression Blend.

Microsoft.Expression.Platform.. Dll doSilverlight

No

Tempo de- assemblyde design de Expression Blend.

ObservaçãoObservação

Assemblies represent functionality boundaries, not namespace boundaries. Geralmente, você encontrará os namespaces que se estendem por mais de um assembly.

The WPF Designer and the Windows Forms Designer Architecture

The WPF Designer architecture is significantly different from the Windows Forms Designer architecture, which is characterized by the IComponent interface and the System.ComponentModel namespace. For more information, see Comparando o Framework Windows Forms Designer para o framework Designer WPF.

Consulte também

Conceitos

Recurso provedores e conectores de recursos

Outros recursos

Fornecimento de metadados de tempo de design

Desenvolvendo controles Windows Forms em tempo de Design

Extensibilidade do WPF Designer