/// <summary>
        /// Read the downloaded xml config file
        /// </summary>
        void getXmlClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                try
                {
                    //add the graphics layers to the map
                    if (!MapHasGraphicsLayer(_layerName))
                        Map.Layers.Add(_graphicsLyr);

                    if (!MapHasGraphicsLayer(_infoLayerName))

                        Map.Layers.Add(_infoGraphicsLyr);

                    _configDoc = XElement.Parse(e.Result);
                    if (_mapServiceManager != null)
                    {
                        _mapServiceManager = null;
                    }
                    _mapServiceManager = new MapServiceManager(Map);
                    if (ValidConfigFile())
                    {
                        PopulateFromConfigSettings();

                    }
                    else
                    {
                        //TODO DECIDE HOW TO HANDLE DISABLE OR ?
                        //SendErrorMsg("Missing critical information in configuration file.");
                    }

                }
                catch (Exception ex)
                {
                    //TODO DISABLE? MAKE NOT VISIBLE
                    //SendErrorMsg("Unable to read configuration file " + ex.Message);
                }
            }
            else
            {
                //TODO DISABLE? MAKE NOT VISIBLE
                //SendErrorMsg("Unable to load configuration file.");
            }
        }
        /// <summary>
        /// Fires search based on selected repository and search text - populates grid
        /// </summary>
        private void SearchButton_Click(object sender, RoutedEventArgs e)
        {
            //TODO need to amend for Default Site, ArcGIS Online and determine if need to make changes for xml
            //Clear the items first
            if (_graphicsLyr != null)
                _graphicsLyr.ClearGraphics();
            if (_infoGraphicsLyr != null)
                _infoGraphicsLyr.ClearGraphics();

            LayoutRootData.Visibility = Visibility.Collapsed;
            if (QueryDetailsDataGrid.ItemsSource != null)
                QueryDetailsDataGrid.ItemsSource = null;

            if (_mapServiceManager != null)
                _mapServiceManager.Close();

            if (_queryResultData == null)
                _queryResultData = new List<QueryResultData>();
            else
                _queryResultData.Clear();

            QueryDetailsDataGrid.ItemsSource = null;
            QueryDetailsDataGrid.ItemsSource = QueryResultData;
            QueryDetailsDataGrid.UpdateLayout();

            //restart
            if (_mapServiceManager == null)
                _mapServiceManager = new MapServiceManager(Map);

            //begin parse
            string lstVal = GeoList.SelectionBoxItem.ToString();

            var match = _geoPortalList.Where(a => a.name == lstVal);
            GeoPortalItem itm = match.First();
            string baseUrl = string.Empty;

            //            baseUrl = itm.url + _format;
            baseUrl = ProcessUrl(itm.url) + _format;
            if (this.LiveDataMaps.IsChecked.Value == true)
            {
                baseUrl = baseUrl + _liveMaps;
            }

            if (SearchText.Text.Length > 0)
            {
                baseUrl = baseUrl + _searchText + SearchText.Text;
            }
            bool includeBbox = false;
            _isFullyWithin = false;
            if (IntersectingRadio.IsChecked == true)
            {
                baseUrl += _overlaps;
                includeBbox = true;

            }
            else if (FullyWithinRadio.IsChecked == true)
            {
                baseUrl += _within;
                includeBbox = true;
                _isFullyWithin = true;
            }

            Envelope extEnv = Map.Extent;
            System.Diagnostics.Debug.WriteLine("original extent: " + Map.Extent);
            if (includeBbox)
            {
                string bboxString = _bbox + extEnv.XMin.ToString() + "," + extEnv.YMin.ToString() + "," + extEnv.XMax.ToString() + "," + extEnv.YMax.ToString();
                baseUrl = baseUrl + bboxString;
            }

            if (_useProxy)
            {

                baseUrl = _proxyUrl + baseUrl;
            }

            WebClient searchClient = new WebClient();
            searchClient.OpenReadCompleted += new OpenReadCompletedEventHandler(searchClient_OpenReadCompleted);
            string abc = HttpUtility.UrlEncode(baseUrl);
            searchClient.OpenReadAsync(new Uri(baseUrl));
        }