private ThrottleTimer _updatePopupVisThrottler; // Throttles

        /// <summary>
        /// Handles when a different layer is selected.
        /// </summary>
        private void Current_SelectedLayerChanged(object sender, EventArgs e)
        {
            // Initialize the throttler, if necessary
            if (_updatePopupVisThrottler == null)
            {
                _updatePopupVisThrottler = new ThrottleTimer(10, () => { UpdatePopupWindow(); });
            }

            // Invoke the throttler. When it executes, it will update the IsOpen property
            // of the popupWindow.
            _updatePopupVisThrottler.Invoke();
        }
        /// <summary>
        /// Handles when feature data grid closes
        /// </summary>
        private void OnDataGridVisibilityChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            // The e.OldValue can be Null, Visible, or Collapsed. If the value was null, this means the application
            // had just started and we don't want to do anything when the Visibility initially changes.
            if (e.OldValue != null)
            {
                string oldValue = e.OldValue.ToString();

                if (oldValue == "Visible" && attributeGridContainer.Visibility == Visibility.Collapsed)
                {
                    if (handleAttributeTableCloseTimer == null)
                    {
                        handleAttributeTableCloseTimer = new ThrottleTimer(10, () =>
                        {
                            if (map.Layers.Contains(temporaryLayer))
                            {
                                map.Layers.Remove(temporaryLayer);
                                temporaryLayer = null;
                            }

                            // If the attribute table closes and the pop-up item has not changed, close the pop-up window.
                            if (!_popupItemChanged)
                            {
                                popupWindow.IsOpen = false;
                            }
                            else
                            {
                                _popupItemChanged = false;
                            }
                        });
                    }

                    handleAttributeTableCloseTimer.Invoke();
                }
            }
        }
        /// <summary>
        /// Handles when feature data grid closes
        /// </summary>
        private void OnDataGridVisibilityChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            // The e.OldValue can be Null, Visible, or Collapsed. If the value was null, this means the application
            // had just started and we don't want to do anything when the Visibility initially changes.
            if (e.OldValue != null)
            {
                string oldValue = e.OldValue.ToString();

                if (oldValue == "Visible" && attributeGridContainer.Visibility == Visibility.Collapsed)
                {
                    if (handleAttributeTableCloseTimer == null)
                    {
                        handleAttributeTableCloseTimer = new ThrottleTimer(10, () =>
                        {
                            if (map.Layers.Contains(temporaryLayer))
                            {
                                map.Layers.Remove(temporaryLayer);
                                temporaryLayer = null;
                            }

                            // If the attribute table closes and the pop-up item has not changed, close the pop-up window.
                            if (!_popupItemChanged)
                            {
                                popupWindow.IsOpen = false;
                            }
                            else
                            {
                                _popupItemChanged = false;
                            }
                        });
                    }

                    handleAttributeTableCloseTimer.Invoke();
                }
            }
        }
        private ThrottleTimer _updatePopupVisThrottler; // Throttles 

        /// <summary>
        /// Handles when a different layer is selected.
        /// </summary>
        private void Current_SelectedLayerChanged(object sender, EventArgs e)
        {

            // Initialize the throttler, if necessary 
            if (_updatePopupVisThrottler == null)
                _updatePopupVisThrottler = new ThrottleTimer(10, () => { UpdatePopupWindow(); });

            // Invoke the throttler. When it executes, it will update the IsOpen property
            // of the popupWindow.
            _updatePopupVisThrottler.Invoke();

        }