/// <summary>
        /// Load/Refresh data
        /// </summary>
        /// <returns></returns>
        public async System.Threading.Tasks.Task RefreshList()
        {
            // Start progress ring until records loaded.
            progressRing.IsActive = true;

            // Set the cbLookFor, cbLookIn and searchbox disabled until views/records loaded.
            cbLookFor.IsEnabled = false;
            cbLookIn.IsEnabled  = false;
            txtSearch.IsEnabled = false;

            // Clear data.
            this.lvList.ItemsSource = null;
            // Show Search button and hide Cancel Button
            btnSearch.Visibility       = Visibility.Visible;
            btnCancelSearch.Visibility = Visibility.Collapsed;
            // Clear any search
            txtSearch.Text = "";


            // If it's regarding, then check if 1st view is selected, which is regarding view.
            if (isRegarding && cbLookIn.SelectedIndex == 0)
            {
                // Then get RelatedData and assign Id
                relatedData = CRMHelper.EntityMetadataExCollection.Where(x => x.EntityMetadata.LogicalName == ReferencedEntityLogicalName).First().RelatedEntities.Where(r => r.ReferencingEntity == (cbLookFor.SelectedItem as EntityMetadataEx).EntityMetadata.LogicalName).First();
                if (relatedData != null)
                {
                    relatedData.Id = ReferencedEntityId;
                }
            }
            else
            {
                relatedData = null;
            }

            // If lookup then obtain PrimaryFieldName
            if (isLookup)
            {
                primaryFieldName = (cbLookFor.SelectedItem as EntityMetadataEx).EntityMetadata.PrimaryNameAttribute;
            }

            // Get Records by passing necessary data.
            this.lvList.ItemsSource = await CRMHelper.RetrieveByFetchXmlForView(
                cbLookIn.SelectedItem as SavedQuery, relatedData, primaryFieldName);

            cbLookFor.IsEnabled       = true;
            cbLookIn.IsEnabled        = true;
            txtSearch.IsEnabled       = true;
            lvList.SelectionMode      = ListViewSelectionMode.Single;
            lvList.IsItemClickEnabled = true;

            //once record loaded, then stop progress ring, and enable comboboxes and search textbox.
            progressRing.IsActive = false;
        }
        /// <summary>
        /// Does Quick Find Search
        /// </summary>
        public async void DoSearch()
        {
            // Check Search Criteria
            if (string.IsNullOrEmpty(txtSearch.Text))
            {
                return;
            }

            // Start progress ring until records loaded.
            progressRing.IsActive = true;

            // Set the cbLookFor, cbLookIn and searchbox disabled until views/records loaded.
            cbLookFor.IsEnabled = false;
            cbLookIn.IsEnabled  = false;
            txtSearch.IsEnabled = false;

            // Clear data.
            this.lvList.ItemsSource = null;

            // Retrieve views by specifing search text, which should return 1 view (quick find view)
            // But do not set views to cbLookIn to let users select any views later on.
            views = await CRMHelper.RetrieveViews((int)CRMHelper.EntityMetadataExCollection.
                                                  Where(x => x.EntityMetadata.LogicalName == (cbLookFor.SelectedItem as EntityMetadataEx).EntityMetadata.LogicalName).
                                                  Select(x => x.EntityMetadata.ObjectTypeCode).FirstOrDefault(),
                                                  false, false, txtSearch.Text + "%");

            // Then retrieve record and assign to ListView
            if (views != null && views.Count != 0)
            {
                this.lvList.ItemsSource = await CRMHelper.RetrieveByFetchXmlForView(views[0], relatedData, primaryFieldName);
            }

            // Once record loaded, then enable comboboxes and search textbox.
            cbLookFor.IsEnabled = true;
            cbLookIn.IsEnabled  = true;
            txtSearch.IsEnabled = true;

            // Hide btnSearch and show btnCancelSearch only after finish searching
            btnSearch.Visibility       = Visibility.Collapsed;
            btnCancelSearch.Visibility = Visibility.Visible;

            progressRing.IsActive = false;
        }