// ***********************************************************************************
        // * User selected a facility type... query for that facility type
        // ***********************************************************************************
        private async void cmbFieldType_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            BufferType resourceType = (BufferType)cmbFacility.SelectedItem;

            if (resourceType.Name == "Select Type")
            {
                return;
            }

            var query = new ESRI.ArcGIS.OperationsDashboard.Query();

            query.WhereClause    = _bufferField + "='" + resourceType.Name + "'";
            query.ReturnGeometry = true;
            query.SpatialFilter  = _mapWidget.Map.Extent;
            query.Fields         = new string[] { "*" };

            BufferLayer layer = (BufferLayer)cmbLayers.SelectedItem;

            var result = await layer.DataSource.ExecuteQueryAsync(query);

            if (result == null || result.Features == null)
            {
                return;
            }
            else
            {
                queryResourceType_ExecuteCompleted(result);
            }
        }
 // ***********************************************************************************
 // * Query the selected resource layer to get the different resource types...
 // ***********************************************************************************
 private void cmbLayers_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (cmbLayers.SelectedIndex > 0)
     {
         rbSelectedFeaturesFromLayer.IsChecked = true;
         BufferLayer bufferLayer = (BufferLayer)cmbLayers.SelectedItem;
         queryBufferLayer(bufferLayer.DataSource);
     }
 }
        public BufferMapToolBar(MapWidget mapWidget, String bufferDataSource, String bufferField)
        {
            InitializeComponent();
            this.DataContext = this;

            // Store a reference to the MapWidget that the toolbar has been installed to.
            _mapWidget = mapWidget;


            // The following parameters are used when user selecting features from a layer.
            // DataSource and Field names need to be specified in the tool settings.
            BufferLayers = new ObservableCollection <BufferLayer>();
            var selectLyr = new BufferLayer();


            if (bufferDataSource == null)
            {
                selectLyr.Name       = "Use Settings for buffer layer";
                selectLyr.DataSource = null;
                BufferLayers.Add(selectLyr);
            }
            else
            {
                _bufferDataSource = bufferDataSource;
                _bufferField      = bufferField;

                selectLyr.Name       = "Select a layer";
                selectLyr.DataSource = null;
                BufferLayers.Add(selectLyr);

                ESRI.ArcGIS.OperationsDashboard.DataSource layerDataSource = null;

                IEnumerable <ESRI.ArcGIS.OperationsDashboard.DataSource> dataSources = OperationsDashboard.Instance.DataSources;
                foreach (ESRI.ArcGIS.OperationsDashboard.DataSource d in dataSources)
                {
                    if (d.Id == _bufferDataSource)
                    {
                        layerDataSource = d;
                        break;
                    }
                }

                BufferTypes = new ObservableCollection <BufferType>();
                var bufferLayer = new BufferLayer();
                bufferLayer.Name       = layerDataSource.Name;
                bufferLayer.DataSource = layerDataSource;
                BufferLayers.Add(bufferLayer);
            }
        }
        public BufferMapToolBar(MapWidget mapWidget, String bufferDataSource, String bufferField)
        {
            InitializeComponent();
            this.DataContext = this; 

            // Store a reference to the MapWidget that the toolbar has been installed to.
            _mapWidget = mapWidget;


            // The following parameters are used when user selecting features from a layer. 
            // DataSource and Field names need to be specified in the tool settings. 
            BufferLayers = new ObservableCollection<BufferLayer>();
            var selectLyr = new BufferLayer();
           

            if (bufferDataSource == null)
            {
                selectLyr.Name = "Use Settings for buffer layer";
                selectLyr.DataSource = null;
                BufferLayers.Add(selectLyr);
            }
            else
            {
                _bufferDataSource = bufferDataSource;
                _bufferField = bufferField;

                selectLyr.Name = "Select a layer";
                selectLyr.DataSource = null;
                BufferLayers.Add(selectLyr);

                ESRI.ArcGIS.OperationsDashboard.DataSource layerDataSource = null;

                IEnumerable<ESRI.ArcGIS.OperationsDashboard.DataSource> dataSources = OperationsDashboard.Instance.DataSources;
                foreach (ESRI.ArcGIS.OperationsDashboard.DataSource d in dataSources)
                {
                    if (d.Id == _bufferDataSource)
                    {
                        layerDataSource = d;
                        break;
                    }
                }

                BufferTypes = new ObservableCollection<BufferType>();
                var bufferLayer = new BufferLayer();
                bufferLayer.Name = layerDataSource.Name;
                bufferLayer.DataSource = layerDataSource;
                BufferLayers.Add(bufferLayer);
            }
        }