Utility Actions
This sample demonstrates the Measure action. To use this action, click the Measure item from the menu in the upper right corner of the application, then click points on the map. In the sample XAML, the action is attached to a Button inside the Grid that comprises the menu. The key element in the XAML is this Button element and the action it contains. Examining this, you can see that an action can easily be attached to a button's click event in XAML. The Measure action has properties to specify whether to display total distance, the distance units, the areal units, the measure mode, the fill symbol, and the name of the target Map control.
Download Sample Application<UserControl x:Class="ArcGISWPFSDK.LocalUtilityActions" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:esri="http://schemas.esri.com/arcgis/client/2009" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"> <Grid x:Name="LayoutRoot" > <Grid.Resources> <DropShadowEffect x:Key="dropShadow" BlurRadius="10" ShadowDepth="10" Direction="-45" Color="Black" Opacity="0.5" /> <LinearGradientBrush x:Key="PanelGradient" EndPoint="0.5,1" StartPoint="0.5,0"> <LinearGradientBrush.RelativeTransform> <TransformGroup> <ScaleTransform CenterY="0.5" CenterX="0.5"/> <SkewTransform CenterY="0.5" CenterX="0.5"/> <RotateTransform Angle="176" CenterY="0.5" CenterX="0.5"/> <TranslateTransform/> </TransformGroup> </LinearGradientBrush.RelativeTransform> <GradientStop Color="#FF145787"/> <GradientStop Color="#FF3D7FAC" Offset="0.184"/> <GradientStop Color="#FF88C5EF" Offset="0.984"/> </LinearGradientBrush> <Style x:Key="CommonBorder" TargetType="Border"> <Setter Property="BorderBrush" Value="White" /> <Setter Property="BorderThickness" Value="1" /> <Setter Property="CornerRadius" Value="5" /> <Setter Property="Background" Value="{StaticResource PanelGradient}" /> <Setter Property="Opacity" Value="1" /> </Style> <esri:SimpleFillSymbol x:Key="DefaultFillSymbol" Fill="#4400FF00" BorderBrush="Red" BorderThickness="1" /> </Grid.Resources> <esri:Map x:Name="MyMap" WrapAround="True" Extent="-15000000,2000000,-7000000,8000000" MinimumResolution="2445.98490512499"> <esri:ArcGISLocalTiledLayer ID="MyBaseLayer" Path="..\\Data\\TPKs\\Topographic.tpk"/> </esri:Map> <Grid HorizontalAlignment="Right" VerticalAlignment="Top" Width="Auto" Height="Auto" Margin="10" > <Border Style="{StaticResource CommonBorder}" Padding="10,3,10,10" Effect="{StaticResource dropShadow}"> <StackPanel> <TextBlock Text="Utility Actions" Foreground="White" FontSize="14" FontWeight="Bold" Margin="4" /> <Button Content="Measure" Margin="2" > <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <esri:MeasureAction AreaUnit="SquareMiles" DisplayTotals="True" DistanceUnit="Miles" MapUnits="Meters" MeasureMode="Polygon" FillSymbol="{StaticResource DefaultFillSymbol}" TargetName="MyMap"/> </i:EventTrigger> </i:Interaction.Triggers> </Button> </StackPanel> </Border> </Grid> </Grid> </UserControl>
5/16/2014