FeatureProvider Class

Adds a class-specific contribution to a feature.

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

public abstract class FeatureProvider

The FeatureProvider type exposes the following members.

  NameDescription
Protected methodFeatureProviderInitializes a new instance of the FeatureProvider class.
Top

  NameDescription
Public methodEqualsDetermines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

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.

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(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();
    }
}


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

Community Additions

ADD
Show: