/// <summary>
        /// Populate element with list of properties
        /// </summary>
        /// <param name="element"></param>
        /// <param name="list"></param>
        private static void PopulateWithIndicatedProperties(this A11yElement element, List <int> list)
        {
            element.Clear();
            if (element.IsSafeToRefresh())
            {
                A11yAutomation.UIAutomationObject.PollForPotentialSupportedProperties((IUIAutomationElement)element.PlatformObject, out int[] ppids, out string[] ppns);

                // build a cache based on the lists
                var cache = DesktopElementHelper.BuildCacheRequest(list, null);

                // buildupdate cached element
                var uia = ((IUIAutomationElement)element.PlatformObject).BuildUpdatedCache(cache);

                var properties = RetrievePropertiesFromCache(uia, list);

                element.Properties = properties.Where(p => !string.IsNullOrEmpty(p.TextValue)).ToDictionary(d => d.Id);

                element.UpdateGlimpse();

                // release previous UIAElement
                Marshal.ReleaseComObject(uia);
                // release cache interface.
                Marshal.ReleaseComObject(cache);
            }
        }
        /// <summary>
        /// Populate member data and testresults are cleaned up.
        /// if there is existing data, clean up first and populate
        /// please don't call it directly but use UpdateElementAction.
        /// it would make Ux and Runtime separation easier since all communication is done via Actions.
        /// </summary>
        /// <param name="element"></param>
        public static void PopulateAllPropertiesWithLiveData(this A11yElement element)
        {
            element.Clear();

            if (element.IsSafeToRefresh())
            {
                element.PopulatePropertiesAndPatternsFromCache();
                element.PopulatePlatformProperties();
            }
        }
        /// <summary>
        /// Populate member data and testresults are cleaned up.
        /// if there is existing data, clean up first and populate
        /// please don't call it directly but use UpdateElementAction. 
        /// it would make Ux and Runtime separation easier since all communication is done via Actions. 
        /// </summary>
        /// <param name="element"></param>
        public static void PopulateAllPropertiesWithLiveData(this A11yElement element)
        {
            if (element == null) throw new ArgumentNullException(nameof(element));

            element.Clear();

            if (element.IsSafeToRefresh())
            {
                element.PopulatePropertiesAndPatternsFromCache();
                element.PopulatePlatformProperties();
            }
        }
        /// <summary>
        /// Start snapshot mode.
        /// </summary>
        /// <param name="e">root element for listening events</param>
        private void StartEventsMode(A11yElement e)
        {
            if (e == null)
            {
                this.AllowFurtherAction = false;
                MessageDialog.Show(Properties.Resources.StartElementDetailViewNoElementIsSelectedMessage);
                this.AllowFurtherAction = true;
            }
            else if (e.IsSafeToRefresh() == false)
            {
                this.AllowFurtherAction = false;
                MessageDialog.Show(Properties.Resources.StartEventsModeElementNotAvailableMessage);
                this.AllowFurtherAction = true;
            }
            else
            {
                // we need to explicitly set the highlighter mode despite of the highlighter button status
                HighlightAction.GetDefaultInstance().HighlighterMode = HighlighterMode.Highlighter;

                this.ctrlEventMode.Clear();

                DisableElementSelector();

                this.ctrlCurMode.HideControl();
                this.ctrlCurMode = this.ctrlEventMode;
                this.ctrlEventMode.CurrentView = EventsView.Config;
                this.ctrlCurMode.ShowControl();

                var sa = SelectAction.GetDefaultInstance();

                // set the root element to listen to.
#pragma warning disable CS4014
                // NOTE: We aren't awaiting this async call, so if you
                // touch it, consider if you need to add the await
                this.ctrlEventMode.SetElement(sa.GetSelectedElementContextId().Value);
#pragma warning restore CS4014
                this.CurrentPage = AppPage.Events;
                this.CurrentView = EventsView.Config;
                PageTracker.TrackPage(this.CurrentPage, this.CurrentView.ToString());
            }
        }