ArcGIS API for Silverlight - Library Reference
EditGeometry Constructor(Map)
See Also  Example Send comments on this topic
ESRI.ArcGIS.Client Namespace > EditGeometry Class > EditGeometry Constructor : EditGeometry Constructor(Map)

map
Initializes a new instance of the EditGeometry class.

Syntax

Visual Basic (Declaration) 
Public Function New( _
   ByVal map As Map _
)
C# 
public EditGeometry( 
   Map map
)

Parameters

map

Example

How to use:

This example code shows the bare minimum settings that need to be enabled in order to edit a Polygon Graphic in a GraphicsLayer using the EditGeometry object. To begin editing click on the Polygon Graphic, make the desired changes, and then click somewhere on the Map outside of the Graphic.

The XAML code in this example is used in conjunction with the code-behind (C# or VB.NET) to demonstrate the functionality.

The following screen shot corresponds to the code example in this page.

Bare-bones code example of using the EditGeometry Class.

XAMLCopy Code
<Grid x:Name="LayoutRoot" Background="White">
            
  <!-- 
  Add a Map Control. 
  Set the Editor.SnapDistance Dependency Property (i.e. Editor.SnapDistanceProperty Field the API Ref Doc). This
  determines the radius in pixels that vertices in a Polygon or Polyline will snap together.
  Wire up the Map.MouseClick Event in code-behind to handle stop editing of the EditGeometry object.
  -->
  <esri:Map x:Name="MyMap" Extent="-16574645,-5541958,13341035,10559275" 
   esri:Editor.SnapDistance="30" Margin="12,153,344,50" MouseClick="MyMap_MouseClick">
   
    <!-- Add a backdrop ArcGISTiledMapServiceLayer. -->
    <esri:ArcGISTiledMapServiceLayer Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/>
    
      <!-- 
      Add a GraphicsLayer with a default Polygon Graphic for editing. Define the display symbology for each Graphic. 
      The GraphicLayer.MouseLeftButtonDown Event is wired up for code-behind functionality. The code-behind function
      will start the editing of the Polygon Graphic.
      -->
      <esri:GraphicsLayer ID="MyGraphicsLayer" MouseLeftButtonDown="GraphicsLayer_MouseLeftButtonDown">
        <esri:GraphicsLayer.Graphics>
        
          <!-- Define the Polygon Graphic and a default symbol.-->
          <esri:Graphic>
            <esri:Polygon>
              <esri:Polygon.Rings>
                <esri:PointCollection>
                  <esri:MapPoint X="-5570316" Y="-1153156" />
                  <esri:MapPoint X="-6961809" Y="335638" />
                  <esri:MapPoint X="-9270798" Y="-437047" />
                  <esri:MapPoint X="-5570316" Y="-1153156" />
                </esri:PointCollection>
              </esri:Polygon.Rings>
            </esri:Polygon>
          <esri:Graphic.Symbol>
            <esri:SimpleFillSymbol Fill="#660000FF" BorderBrush="Blue" BorderThickness="1" />
          </esri:Graphic.Symbol>
        </esri:Graphic>
      </esri:GraphicsLayer.Graphics>
    </esri:GraphicsLayer>
    
  </esri:Map>
  
  <!-- Provide the instructions on how to use the sample code. -->
  <TextBlock Height="147" HorizontalAlignment="Left" Name="TextBlock1" VerticalAlignment="Top" Width="759" 
  TextWrapping="Wrap" Text="This example code shows the bare minimum settings that need to be enabled in 
  order to edit a Polygon Graphic in a GraphicsLayer using the EditGeometry object. To begin editing 
  click on the Polygon Graphic, make the desired changes, and then click somewhere on the Map outside 
  of the Graphic." />
  
</Grid>
C#Copy Code
// Global/Member variable for the EditGeometry object (enables editing Polygon and Polyline graphics).
private ESRI.ArcGIS.Client.EditGeometry _EditGeometry;
  
public MainPage()
{
  InitializeComponent();
  
  // Create a new instance of the EditGeometry object.
  _EditGeometry = new ESRI.ArcGIS.Client.EditGeometry(MyMap);
  
  // Enable editing with the EditGeometry object.
  _EditGeometry.IsEnabled = true;
}
            
private void GraphicsLayer_MouseLeftButtonDown(object sender, ESRI.ArcGIS.Client.GraphicMouseButtonEventArgs e)
{
  // The user has clicked on the Polygon Graphic in the GraphicsLayer.
  
  // Keep this event handler from bubbling up to other event handlers. We will perform all actions necessary in
  // this event handler. 
  e.Handled = true;
  
  // Start the editing of the Polygon Graphic.
  _EditGeometry.StartEdit(e.Graphic);
}
            
private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
{
  // The user clicked somewhere in the Map Contol but NOT directly over the Graphic being edited.
  
  // Stop the editing of the Graphic.
  _EditGeometry.StopEdit();
}
VB.NETCopy Code
' Global/Member variable for the EditGeometry object (enables editing Polygon and Polyline graphics).
Private _EditGeometry As ESRI.ArcGIS.Client.EditGeometry
            
Public Sub New()
  InitializeComponent()
  
  ' Create a new instance of the EditGeometry object.
  _EditGeometry = New ESRI.ArcGIS.Client.EditGeometry(MyMap)
  
  ' Enable editing with the EditGeometry object.
  _EditGeometry.IsEnabled = True
  
End Sub
            
Private Sub GraphicsLayer_MouseLeftButtonDown(sender As System.Object, e As ESRI.ArcGIS.Client.GraphicMouseButtonEventArgs)
  
  ' The user has clicked on the Polygon Graphic in the GraphicsLayer.
  
  ' Keep this event handler from bubbling up to other event handlers. We will perform all actions necessary in
  ' this event handler. 
  e.Handled = True
  
  ' Start the editing of the Polygon Graphic.
  _EditGeometry.StartEdit(e.Graphic)
  
End Sub
            
Private Sub MyMap_MouseClick(sender As System.Object, e As ESRI.ArcGIS.Client.Map.MouseEventArgs)
  
  ' The user clicked somewhere in the Map Contol but NOT directly over the Graphic being edited.
  
  ' Stop the editing of the Graphic.
  _EditGeometry.StopEdit()
  
End Sub

Requirements

Target Platforms: Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family, Windows 7

See Also

© ESRI, Inc. All Rights Reserved.