I would like to programmatically draw a polygon on an ESRI map. I'm using this code to draw a polygon with the mouse but I'm really new to this technology and I'm a little bit lost ... Here is my MainWindow :

public partial class MainWindow : Window
    Draw _myDrawObject;
    private GraphicsLayer _graphicsLayer;

    public MainWindow()
        _myDrawObject = new Draw(esriMap)
                               FillSymbol = LayoutRoot.Resources["RedFillSymbol"] as FillSymbol

        _myDrawObject.DrawComplete += MyDrawObjectDrawComplete;

    private void EsriMapMouseClick(object sender, Map.MouseEventArgs e)
        _myDrawObject.DrawMode = DrawMode.Polygon;
        _myDrawObject.IsEnabled = true;

    private void MyDrawObjectDrawComplete(object sender, ESRI.ArcGIS.Client.DrawEventArgs args)

        var graphic = new Graphic()
                                  Geometry = args.Geometry,
                                  Symbol = LayoutRoot.Resources["BlueFillSymbol"] as FillSymbol

        _graphicsLayer = esriMap.Layers["MyGraphicsLayer"] as GraphicsLayer;

        if (_graphicsLayer != null)


I already went to the ArcGIS help site (http://resources.arcgis.com/content/web-based-help) but i can't find the solution. Any ideas or tips ?

Feel free to ask me some questions if you want more details!


1 Answer 1


If you installed the WPF SDK in the normal location, you can go to this folder and find an interactive sample application:

C:\ArcGIS\WPF1.0\SDK\Samples\Sample Application\Sample Application.exe

There is a list of demo categories on the left, so expand the Editing group. And then inside that are two more groups: Edit Controls and Edit Tools.

Look at the Edit Tools - Auto Save example. There are tabs on the example so you can switch between Live Sample/XAML/Code Behind. Copy and paste into your own project, and you will have a working example. Then you can customize or edit as needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.