Microsoft.Phone.Applications.UnitConverter.View.CategorySelection.OnPivotSelectionChanged C# (CSharp) Method

OnPivotSelectionChanged() private method

Event that indicates we have moved to a new pivot page
private OnPivotSelectionChanged ( object sender, System.Windows.Controls.SelectionChangedEventArgs e ) : void
sender object The source of the event.
e System.Windows.Controls.SelectionChangedEventArgs instance containing the event data.
return void
        private void OnPivotSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            PivotItem pivotItem = e.AddedItems[0] as PivotItem;
            this.viewModel.ProcessPivotSelectionChange(pivotItem, this.favoritesListView,
                this.favoritesNoItems);

            /* If this is the first time this function is called, the pivot is hidden so 
             * that we will be able to navigate to the desired pivot
             * item before showing the pivot control.
             * However, the header animation does not always complete before the pivot is shown.
             * To compensate for this, if we are not going to the default pivot page, we will 
             * enable a layout event handler on the pivot that will be called as the header 
             * animation progresses. A Background thread will monitor the updates, and on the 
             * last update, will wait some time, and then display the pivot
             */
            if (this.pivot.Opacity != 1)
            {
                if (this.requestedPivotDataSelectionIndex != 1)
                {
                    Dispatcher.BeginInvoke(() =>
                        {
                            this.pivot.LayoutUpdated += new EventHandler(pivot_LayoutUpdated);
                            this.worker.RunWorkerAsync(null);
                        });
                }
                else
                {
                    this.pivot.Opacity = 1;
                }
            }
          }