Behaviors and actions
Microsoft Expression Blend 4 defines a standard for behaviors, which are reusable pieces of packaged code that can be dragged onto any object and fine-tuned by changing their properties. Behaviors allow you to add interactivity to your applications without having to write any code. The Behavior application programming interface (API) consists of three core classes: Trigger, Action, and Behavior. The ArcGIS Runtime SDK for WPF includes a set of behaviors and actions in the ESRI.ArcGIS.Client.Behaviors assembly that can be used to define interactive relationships between user input, and map behavior and content.
To use behaviors and actions in your application, you must add a reference to the System.Windows.Interactivity assembly. This assembly is included with the Expression Blend 4 product or the Expression Blend 4 SDK (currently included with Expression Blend 4).
In all code examples below, references to the System.Windows.Interactivity, ESRI.ArcGIS.Client, and ESRI.ArcGIS.Client.Behaviors assemblies were added to the project, and a namespace reference for each was added to the window:
xmlns:esri="http://schemas.esri.com/arcgis/client/2009"
xmlns:esriBehaviors="clr-namespace:ESRI.ArcGIS.Client.Behaviors;assembly=ESRI.ArcGIS.Client.Behaviors"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
Behaviors
A behavior is composed of a trigger and an action for a specific control. All behaviors included with the ArcGIS Runtime SDK for WPF are designed to work with a predefined event on the map (trigger) that generates (action) a result. The behaviors are packaged for you; therefore, you only need to add a behavior to a map to use it. The table below lists the map behaviors, provides a description, and shows a code example for each:
Behavior | Description | Code example |
---|---|---|
ConstrainExtentBehavior |
Limits the map extent to an envelope. The user cannot navigate outside the envelope defined in the behavior. |
|
MaintainExtentBehavior |
Maintains the current extent when the map is resized. |
|
ShowCoordinatesBehavior | Shows map coordinates next to the mouse cursor when hovering the mouse pointer over the map. |
|
Actions
An action is composed of a trigger and a target. The trigger is an event, such as the click event of a button. A target is where the results of the action are used or displayed. Actions included with the ArcGIS Runtime SDK for WPF will always target the map and its contents. Actions include adding graphics, navigating the map, and working with layers. The table below lists available actions, provides a description, and shows a code example for each:
Action | Description | Code example |
---|---|---|
ClearGraphicsAction |
Clears all graphics in a graphics layer. |
|
MeasureAction | Shows measure distance, radius, and area. |
|
PanToAction | Pans to a specified geometry. |
|
RedlineAction | Draws graphics on the map and adds them to a graphics layer. |
|
SpatialQueryAction | Draws geometry on the map to query features in a feature layer. Draws the results in a graphics layer. |
|
ToggleLayerAction | Toggles the visibility of a layer. |
|
UpdateFeatureLayerAction | Refreshes the contents of a feature layer. |
|
ZoomToAction | Zooms to a specified geometry. If the geometry is a point, the map will pan. |
|
ZoomToFullExtentAction | Zooms to the full extent of all layers. |
|
ZoomToLayerAction | Zooms to the extent of a specified layer. |
|