Customizing a pop-up menu when a feature is activated from a list

Across the out-of-the-box application, you probably have seen a pop-up menu showing up when a feaure on a Page is activated. Very often the menu will show a collection of operations that you can apply to the activated feature, for example, Browse on Map, View Attributes, Edit Attributes, Delete, Add to WorkList, Cancel, and so on. This presents the user a similar experience as the context menu in Win32 platform.

To create your own, customized pop-up menu, application framework exposes an extensible point where you can achieve this. As a matter of fact, each of the menu items on the pop-up menu is called a FeatureActionItem, representing an Action that you can apply to a Feature. Whenever a project is creating a list of FeatureActionItems, it will fire an event called CreatingFeatureActionItems. By listening to this event, you will get the chance to customize the list of FeatureActionItems showing up on the pop-up menu. Note that this event will be fired when the Project is constructing a list of FeatureActionItems, and this could happen on different pages, such as FeatureListPage, IdentifyResultsPage, SearchResultsPage, and so on.

Therefore, if you simply subscribe to Project.CreatingFeatureActionItems event and customize the menu, it will be effective for any page that Project constructs a list of FeatureActionItems for. If you want to customize the pop-up menu for a specific type of page, you will need to check the Context in which the event gets fired.

Through FeatureActionEventArgs, you can get a list of ActionItems through ActionItems property, and add a new FeatureActionItem or remove an existing FeatureActionItem. The Context property allows you to check the type of IPage from which this event is fired, and you can get access to the activated Feature through SelectedFeature.


9/20/2011