private void LoadDataAndSetPIItems()
        {
            Pivot p = BuildP;

            if (p != null)
            {
                PivotItem pi = p.SelectedItem as PivotItem;
                if (pi != null)
                {
                    if (pi.Name.Equals("definitionsPI"))
                    {
                        if (buildDefList == null || buildDefList.Count < 1 || ifRefresh)
                        {
                            ShowProgressBar();
                            Task.Factory.StartNew(() =>
                            {
                                buildDefList = VSTSService.GetBuildDefinitions();
                            }).ContinueWith(async(Task t) =>
                            {
                                await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                                {
                                    source = new List <ItemDetails>();

                                    foreach (var bd in buildDefList)
                                    {
                                        source.Add(new ItemDetails(bd.Name));
                                    }
                                    itemSource = AlphaKeyGroup <ItemDetails> .CreateGroups(source,
                                                                                           CultureInfo.CurrentUICulture, s => s.Name, true);

                                    ((CollectionViewSource)Resources["DefinitionGroups"]).Source = itemSource;
                                    manuallyselected = true;
                                    HideProgressBar();
                                }
                                                               );
                            });
                        }
                        else
                        {
                            ((CollectionViewSource)Resources["DefinitionGroups"]).Source = itemSource;
                            manuallyselected = true;
                        }
                    }
                    else if (pi.Name.Equals("completedBuildsPI"))
                    {
                        if (completedBuildsList == null || completedBuildsList.Count < 1 || ifRefresh)
                        {
                            ShowProgressBar();
                            Task.Factory.StartNew(() =>
                            {
                                completedBuildsList = VSTSService.GetBuilds();
                            }).ContinueWith(async(Task t) =>
                            {
                                await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                                {
                                    completedBuildsLV.ItemsSource = completedBuildsList;
                                    HideProgressBar();
                                });
                            });
                        }
                        else
                        {
                            completedBuildsLV.ItemsSource = completedBuildsList;
                        }
                    }
                    else if (pi.Name.Equals("queuedBuildsPI"))
                    {
                        if (queuedBuildsList == null || queuedBuildsList.Count < 1 || ifRefresh)
                        {
                            ShowProgressBar();
                            Task.Factory.StartNew(() =>
                            {
                                queuedBuildsList = VSTSService.GetQueuedBuilds();
                            }).ContinueWith(async(Task t) =>
                            {
                                await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                                {
                                    queuedBuildsLV.ItemsSource = queuedBuildsList;
                                    HideProgressBar();
                                });
                            });
                        }
                        else
                        {
                            queuedBuildsLV.ItemsSource = queuedBuildsList;
                        }
                    }
                    //else if(pi.Name.Equals(""))
                    //{
                    //    showCB();
                    //}
                    ifRefresh = false;
                }
            }
        }