Export (0) Print
Expand All

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

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:
© 2014 Microsoft