UtilityAction

  1 <UserControl
  2     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  5     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  6     xmlns:esri="http://schemas.esri.com/arcgis/client/2009" 
  7     xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" 
  8     xmlns:esriBehaviors="clr-namespace:ESRI.ArcGIS.Client.Behaviors;assembly=ESRI.ArcGIS.Client.Behaviors"
  9     xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
 10     x:Class="UtilityAction.MainPage"
 11     mc:Ignorable="d"
 12     d:DesignHeight="300" d:DesignWidth="400">
 13 
 14     <Grid x:Name="LayoutRoot" Background="White">
 15 
 16         <Grid.Resources>
 17             <LinearGradientBrush x:Key="CommonGradient" StartPoint="0.5,0" EndPoint="0.5,1">
 18                 <GradientStop Offset="0" Color="#99919191"/>
 19                 <GradientStop Offset="0.25" Color="#aa919191"/>
 20                 <GradientStop Offset="0.75" Color="#cc919191"/>
 21             </LinearGradientBrush>
 22             <Style x:Key="CommonBorder" TargetType="Border">
 23                 <Setter Property="BorderBrush" Value="White" />
 24                 <Setter Property="BorderThickness" Value="1" />
 25                 <Setter Property="CornerRadius" Value="5" />
 26                 <Setter Property="Background" Value="{StaticResource CommonGradient}" />
 27                 <Setter Property="Opacity" Value="1" />
 28             </Style>
 29             <Style x:Key="MenuItem" TargetType="Button">
 30                 <Setter Property="Foreground" Value="White"/>
 31                 <Setter Property="HorizontalAlignment" Value="Left"/>
 32                 <Setter Property="VerticalAlignment" Value="Center"/>
 33                 <Setter Property="HorizontalContentAlignment" Value="Left"/>
 34                 <Setter Property="FontSize" Value="12" />
 35                 <Setter Property="Template">
 36                     <Setter.Value>
 37                         <ControlTemplate TargetType="Button">
 38                             <Grid>
 39                                 <VisualStateManager.VisualStateGroups>
 40                                     <VisualStateGroup x:Name="CommonStates">
 41                                         <VisualState x:Name="Normal">
 42                                             <Storyboard>
 43                                                 <DoubleAnimation To="0" FillBehavior="HoldEnd" 
 44                                                      Storyboard.TargetName="menuItemHighlight" 
 45                                                      Storyboard.TargetProperty="Opacity" 
 46                                                      Duration="0:0:0.3" />
 47                                             </Storyboard>
 48                                         </VisualState>
 49                                         <VisualState x:Name="MouseOver">
 50                                             <Storyboard>
 51                                                 <DoubleAnimation To="0.15" FillBehavior="HoldEnd" 
 52                                                      Storyboard.TargetName="menuItemHighlight" 
 53                                                      Storyboard.TargetProperty="Opacity" 
 54                                                      Duration="0:0:0.3" />
 55                                             </Storyboard>
 56                                         </VisualState>
 57                                     </VisualStateGroup>
 58                                 </VisualStateManager.VisualStateGroups>
 59                                 <Rectangle x:Name="menuItemHighlight" Fill="#FFFFFFFF" 
 60                                            Opacity="0" Margin="0" />
 61                                 <ContentPresenter
 62                                     Content="{TemplateBinding Content}"
 63                                     ContentTemplate="{TemplateBinding ContentTemplate}"
 64                                     VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
 65                                     HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
 66                                     Margin="{TemplateBinding Padding}" />
 67                             </Grid>
 68                         </ControlTemplate>
 69                     </Setter.Value>
 70                 </Setter>
 71             </Style>
 72             <esri:SimpleFillSymbol x:Key="DefaultFillSymbol" Fill="#4400FF00" BorderBrush="Red" 
 73                 BorderThickness="1" />
 74         </Grid.Resources>
 75 
 76         <esri:Map x:Name="MyMap" WrapAround="True">
 77             <esri:ArcGISTiledMapServiceLayer ID="MyBaseLayer" 
 78                 Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
 79             <esri:GraphicsLayer ID="MeasureGraphicsLayer"></esri:GraphicsLayer>
 80         </esri:Map>
 81 
 82         <Grid HorizontalAlignment="Right" VerticalAlignment="Top" Width="Auto" Height="Auto" Margin="10" >
 83             <Border Style="{StaticResource CommonBorder}" Padding="10,3,10,3">
 84                 <Border.Effect>
 85                     <DropShadowEffect />
 86                 </Border.Effect>
 87                 <StackPanel>
 88                     <TextBlock Text="Utility Actions" Foreground="White" FontSize="14" FontWeight="Bold" Margin="4" />
 89 
 90                     <Button Style="{StaticResource MenuItem}"                             
 91                             Content="Polygon Measure"  >
 92                         <i:Interaction.Triggers>
 93                             <i:EventTrigger EventName="Click">
 94                                 <esri:MeasureAction                                  
 95                                     AreaUnit="SquareMiles"
 96                                     DisplayTotals="True"
 97                                     DistanceUnit="Miles"
 98                                     MapUnits="Meters"
 99                                     MeasureMode="Polygon"                                   
100                                     FillSymbol="{StaticResource DefaultFillSymbol}"
101                                     TargetName="MyMap"/>
102                             </i:EventTrigger>
103                         </i:Interaction.Triggers>
104                     </Button>
105                     <Button Style="{StaticResource MenuItem}"                             
106                             Content="Polyline Measure"  >
107                         <i:Interaction.Triggers>
108                             <i:EventTrigger EventName="Click">
109                                 <esri:MeasureAction                                  
110                                     AreaUnit="SquareMiles"
111                                     DisplayTotals="True"
112                                     DistanceUnit="Miles"
113                                     MapUnits="Meters"
114                                     MeasureMode="Polyline"                                   
115                                     FillSymbol="{StaticResource DefaultFillSymbol}"
116                                     TargetName="MyMap"/>
117                             </i:EventTrigger>
118                         </i:Interaction.Triggers>
119                     </Button>
120                     <Button Style="{StaticResource MenuItem}"                             
121                             Content="Radius Measure"  >
122                         <i:Interaction.Triggers>
123                             <i:EventTrigger EventName="Click">
124                                 <esri:MeasureAction                                  
125                                     AreaUnit="SquareMiles"
126                                     DisplayTotals="True"
127                                     DistanceUnit="Miles"
128                                     MapUnits="Meters"
129                                     MeasureMode="Radius"                                   
130                                     FillSymbol="{StaticResource DefaultFillSymbol}"
131                                     TargetName="MyMap"/>
132                             </i:EventTrigger>
133                         </i:Interaction.Triggers>
134                     </Button>
135 
136                 </StackPanel>
137             </Border>
138         </Grid>
139 
140 
141 
142 
143 
144 
145     </Grid>
146 </UserControl>
原文地址:https://www.cnblogs.com/rockman/p/3325470.html