Save Package - WPF

Discussion created by chumma on Feb 26, 2014
Latest reply on Feb 27, 2014 by MBranscomb-esristaff

We are loading a MAP package in WPF and updating symbology classification and other items it by creating local service and dynamic layers.

Can you please let us know is there any way we can update all our changes we did in dynamic layer back to the MAP package or to MXD in WPF??

Code is shown below. I want to add the changes did to the "arcGISLocalDynamicMapServiceLayer" back to the package or to a MXD file.

Can anyone kindly let me know if we have any options for this??


   localMapService = new LocalMapService
                Path = "MPK PATH",
                EnableDynamicLayers = true,

            // Start the local map service
            localMapService.StartAsync((mapService) =>
                // Once the LocalMapServce has started create a new local dynamic map service layer based on the local map service
                _arcGISLocalDynamicMapServiceLayer = new ArcGISLocalDynamicMapServiceLayer(localMapService)
                    //ID = "MapService",
                    ID = AppConsts.mapLayerId,
                    //ImageFormat = ArcGISDynamicMapServiceLayer.RestImageFormat.PNG32,
                    EnableDynamicLayers = true,

                // Set up an event handler for the layer initialized event
                _arcGISLocalDynamicMapServiceLayer.Initialized += (s, e) =>
                    Random _random = new Random();
                    LayerDrawingOptions _layerDrawingOptions;
                    _layerDrawingOptions = new LayerDrawingOptions();
                    ClassificationMethod classificationMethod = (ClassificationMethod)Enum.Parse(typeof(ClassificationMethod), strDistributionMethod);
                    var generateDataClassesTask = new GenerateRendererTask(_arcGISLocalDynamicMapServiceLayer.Url + "/" + _arcGISLocalDynamicMapServiceLayer.Layers.First(l => l.Name == layerName).ID.ToString());

                    //Event fire only if we execute Async - FOR DATA Window Generation
                    generateDataClassesTask.ExecuteCompleted += new EventHandler<GenerateRendererResultEventArgs>(generateDataClassesTask_ExecuteCompleted);

                    System.Collections.ObjectModel.ObservableCollection<ColorRamp> colorRamps;

                    //colorRamps = cTheme.GetTruvenDefaultColorRamp();

                    colorRamps = cTheme.GetColorRamp(cThemeKeys.ColorMDB, cThemeKeys.ColorTable, entityName);

                    // Build the GenerateDataClassesParameters to submit to the GenerateDataClassesTask
                    var generateDataClassesParameters = new GenerateRendererParameters
                        // Create a ClassBreaksDefinition to create a ClassBreaksRenderer
                        ClassificationDefinition = new ClassBreaksDefinition
                            BreakCount = breakCount,
                            ClassificationField = themecol,
                            ClassificationMethod = classificationMethod,
                            ColorRamps = colorRamps,

                    // Call the synchronous Execute method on the GenerateDataClassesTask
                    GenerateRendererResult generateDataClassesResult = generateDataClassesTask.Execute(generateDataClassesParameters);

                    //--- To Generate Data Window - ASync Execution is required (to call other methods)
                    if (generateDataClassesTask.IsBusy)


                    // Set the Renderer property on the LayerDrawingOptions
                    _layerDrawingOptions.Renderer = generateDataClassesResult.Renderer as ESRI.ArcGIS.Client.ClassBreaksRenderer;

                    // Create a new layer drawing options collection and set the layer drawing options property on the local dynamic map service layer
                    _arcGISLocalDynamicMapServiceLayer.LayerDrawingOptions = new LayerDrawingOptionsCollection() { _layerDrawingOptions };

                        mapMain.Extent = _arcGISLocalDynamicMapServiceLayer.InitialExtent;

                    ESRI.ArcGIS.Client.ClassBreaksRenderer classRenderer = ((ESRI.ArcGIS.Client.ClassBreaksRenderer)(((ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer)(mapMain.Layers[1])).LayerDrawingOptions[0].Renderer));

                    cMapWork.SetLegendItemsDataCountByClassBreaks(classRenderer, classificationMethod);

                    ((ESRI.ArcGIS.Client.Layer)(_arcGISLocalDynamicMapServiceLayer)).Opacity = layerOpacity;
                    _arcGISLocalDynamicMapServiceLayer.ShowLegend = true;


                // Add the layer to the map