FeatureProvider Class

Adds a class-specific contribution to a feature.

Inheritance Hierarchy

System.Object
  Microsoft.Windows.Design.Features.FeatureProvider
    Microsoft.Windows.Design.Interaction.Adapter
    Microsoft.Windows.Design.Interaction.AdornerProvider
    Microsoft.Windows.Design.Interaction.ContextMenuProvider
    Microsoft.Windows.Design.Interaction.TaskProvider
    Microsoft.Windows.Design.Model.DefaultInitializer
    Microsoft.Windows.Design.Model.DesignModeValueProvider

Namespace:  Microsoft.Windows.Design.Features
Assembly:  Microsoft.Windows.Design.Extensibility (in Microsoft.Windows.Design.Extensibility.dll)

Syntax

'Declaration
Public MustInherit Class FeatureProvider
public abstract class FeatureProvider
public ref class FeatureProvider abstract
[<AbstractClass>]
type FeatureProvider =  class end
public abstract class FeatureProvider

The FeatureProvider type exposes the following members.

Constructors

  Name Description
Protected method FeatureProvider Initializes a new instance of the FeatureProvider class.

Top

Methods

  Name Description
Public method Equals Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Remarks

Derive from the abstract FeatureProvider class to extend the design-time for your custom controls.

Feature providers are managed by feature connectors and are associated to objects through the FeatureAttribute metadata attribute. The feature connector discovers FeatureProvider types from this metadata. The FeatureManager identifies the required feature connector for every feature provider discovered.

Common feature provider implementations include selection adorners, context menus, and property editors.

To attach a feature provider to the primary selection on the design surface, derive from one of the feature providers with the PrimarySelectionPolicy applied, for example PrimarySelectionAdornerProvider or

PrimarySelectionContextMenuProvider.

Examples

The following code example shows how to derive from the FeatureProvider class to implement a custom feature provider named DiagnosticsMenuProvider with a custom service named IDiagnosticsService. For a complete code listing, see How to: Create a Custom Feature Connector.

' The DiagnosticsMenuProvider class adds a context menu item
' that displays a dialog box listing the currently running and 
' pending feature connectors. 
<FeatureConnector(GetType(DiagnosticsFeatureConnector))>  _
Public Class DiagnosticsMenuProvider
    Inherits PrimarySelectionContextMenuProvider

    Public Sub New() 
        Dim action As New MenuAction("Feature Diagnostics...")

        AddHandler action.Execute, AddressOf action_Execute 

        Items.Add(action)    
    End Sub

    Sub action_Execute(ByVal sender As Object, ByVal e As MenuActionEventArgs) 
        Dim service As IDiagnosticsService = e.Context.Services.GetRequiredService(Of IDiagnosticsService)()

        service.ShowWindow()

    End Sub

End Class
// The DiagnosticsMenuProvider class adds a context menu item
// that displays a dialog box listing the currently running and 
// pending feature connectors. 
[FeatureConnector(typeof(DiagnosticsFeatureConnector))]
public class DiagnosticsMenuProvider : PrimarySelectionContextMenuProvider 
{
    public DiagnosticsMenuProvider() 
    {
        MenuAction action = new MenuAction("Feature Diagnostics...");

        action.Execute += new EventHandler<MenuActionEventArgs>(action_Execute); 

        Items.Add(action);
    }

    void action_Execute(object sender, MenuActionEventArgs e)
    {
        IDiagnosticsService service = 
            e.Context.Services.GetRequiredService<IDiagnosticsService>();

        service.ShowWindow();
    }
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Microsoft.Windows.Design.Features Namespace

FeatureConnector<TFeatureProviderType>

FeatureManager

PrimarySelectionAdornerProvider

PrimarySelectionContextMenuProvider

Other Resources

How to: Create a Custom Feature Connector

Feature Providers and Feature Connectors

Understanding WPF Designer Extensibility