public void GoToItem(PivotItem item)
        {
            if (item == null || item == selectedItem)
                return;

            var widthToScroll = 0.0;
            int index;
            for (index = 0; index < Items.Count; index++)
            {
                if (Items[index] == item)
                {
                    internalIndex = index;
                    break;
                }
                widthToScroll += ((PivotItem)Items[index]).ActualWidth;
            }

            mediator.HorizontalOffset = scroller.HorizontalOffset;
            var sb = mediator.Resources["Storyboard1"] as Storyboard;
            var frame = (EasingDoubleKeyFrame)mediator.FindName("edkf");
            frame.Value = widthToScroll;
            sb.Completed -= sb_Completed;
            sb.Completed += sb_Completed;
            sb.Begin();

            RaiseEvent(new RoutedEventArgs(SelectionChangedEvent));
        }
Esempio n. 2
0
        public void GoToItem(PivotItem item)
        {
            if (item == null || item == selectedItem)
            {
                return;
            }

            var widthToScroll = 0.0;
            int index;

            for (index = 0; index < Items.Count; index++)
            {
                if (Items[index] == item)
                {
                    internalIndex = index;
                    break;
                }
                widthToScroll += ((PivotItem)Items[index]).ActualWidth;
            }

            mediator.HorizontalOffset = scroller.HorizontalOffset;
            var sb    = mediator.Resources["Storyboard1"] as Storyboard;
            var frame = (EasingDoubleKeyFrame)mediator.FindName("edkf");

            frame.Value   = widthToScroll;
            sb.Completed -= sb_Completed;
            sb.Completed += sb_Completed;
            sb.Begin();

            RaiseEvent(new RoutedEventArgs(SelectionChangedEvent));
        }
Esempio n. 3
0
        private void scroller_ScrollChanged(object sender, ScrollChangedEventArgs e)
        {
            var position = 0.0;

            for (var i = 0; i < Items.Count; i++)
            {
                var pivotItem   = ((PivotItem)Items[i]);
                var widthOfItem = pivotItem.ActualWidth;
                if (e.HorizontalOffset <= (position + widthOfItem - 1))
                {
                    selectedItem = pivotItem;
                    if (headers.SelectedItem != selectedItem)
                    {
                        headers.SelectedItem = selectedItem;
                        internalIndex        = i;
                        SelectedIndex        = i;

                        RaiseEvent(new RoutedEventArgs(SelectionChangedEvent));
                    }

                    break;
                }

                position += widthOfItem;
            }
        }
Esempio n. 4
0
 private static void SelectedItemChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
 {
     if (e.NewValue != e.OldValue)
     {
         Pivot pivot    = (Pivot)dependencyObject;
         int   newValue = (int)e.NewValue;
         if (pivot.internalIndex != pivot.SelectedIndex && newValue >= 0 && newValue < pivot.Items.Count)
         {
             PivotItem item = (PivotItem)pivot.Items[newValue];
             pivot.headers.SelectedItem = item;
             pivot.GoToItem(item);
         }
     }
 }
Esempio n. 5
0
    public void AutoScrollToItem(PivotItem pivotItem)
    {
      if (mediator == null || scroller == null)
        return;

      IsAutoScrolling = true;

      var widthToScroll = 0.0;
      int index;
      for (index = 0; index < Items.Count; index++)
      {
        if (Items[index] == pivotItem)
        {
          internalIndex = index;
          break;
        }
        widthToScroll += ((PivotItem)Items[index]).ActualWidth;
      }

      SelectedIndex = internalIndex;

      headers.SelectedIndex = internalIndex;

      RaiseEvent(new RoutedEventArgs(SelectionChangedEvent));
      var horizontalOffset = scroller.HorizontalOffset;

      mediator.SetCurrentValue(ScrollViewerOffsetMediator.HorizontalOffsetProperty, horizontalOffset);

      var sb = mediator.Resources["Storyboard1"] as Storyboard;
      var frame = (EasingDoubleKeyFrame)mediator.FindName("edkf");

      frame.Value = widthToScroll;
      sb.Completed -= sb_Completed;
      sb.Completed += sb_Completed;
      sb.Begin();
    }
Esempio n. 6
0
 public void GoToItem(PivotItem item)
 {
     if (item != null)
     {
         if (item != this.selectedItem)
         {
             double actualWidth = 0;
             int    num         = 0;
             while (true)
             {
                 if (num >= base.Items.Count)
                 {
                     break;
                 }
                 else if (base.Items[num] != item)
                 {
                     actualWidth += ((PivotItem)base.Items[num]).ActualWidth;
                     num++;
                 }
                 else
                 {
                     this.internalIndex = num;
                     break;
                 }
             }
             this.mediator.HorizontalOffset = this.scroller.HorizontalOffset;
             Storyboard storyboard = this.mediator.Resources["Storyboard1"] as Storyboard;
             ((EasingDoubleKeyFrame)this.mediator.FindName("edkf")).Value = actualWidth;
             storyboard.Completed -= new EventHandler(this.sb_Completed);
             storyboard.Completed += new EventHandler(this.sb_Completed);
             storyboard.Begin();
             base.RaiseEvent(new RoutedEventArgs(Pivot.SelectionChangedEvent));
             return;
         }
     }
 }
Esempio n. 7
0
        private void scroller_ScrollChanged(object sender, ScrollChangedEventArgs e)
        {
            double num  = 0;
            int    num1 = 0;

            while (true)
            {
                if (num1 < base.Items.Count)
                {
                    PivotItem item        = (PivotItem)base.Items[num1];
                    double    actualWidth = item.ActualWidth;
                    if (e.HorizontalOffset <= num + actualWidth - 1)
                    {
                        this.selectedItem = item;
                        if (this.headers.SelectedItem == this.selectedItem)
                        {
                            break;
                        }
                        this.headers.SelectedItem = this.selectedItem;
                        this.internalIndex        = num1;
                        this.SelectedIndex        = num1;
                        base.RaiseEvent(new RoutedEventArgs(Pivot.SelectionChangedEvent));
                        return;
                    }
                    else
                    {
                        num += actualWidth;
                        num1++;
                    }
                }
                else
                {
                    break;
                }
            }
        }
 void scroller_ScrollChanged(object sender, ScrollChangedEventArgs e)
 {
     var position = 0.0;
     for (int i = 0; i < Items.Count; i++)
     {
         var pivotItem = ((PivotItem)Items[i]);
         var widthOfItem = pivotItem.ActualWidth;
         if (e.HorizontalOffset <= (position + widthOfItem - 1))
         {
             selectedItem = pivotItem;
             if (headers.SelectedItem != selectedItem)
             {
                 headers.SelectedItem = selectedItem;
                 internalIndex = i;
                 SelectedIndex = i;
             }
             break;
         }
         position += widthOfItem;
     }
 }
Esempio n. 9
0
    void scroller_ScrollChanged(object sender, ScrollChangedEventArgs e)
    {
      if (IsAutoScrolling)
        return;

      IsManualScrolling = true;

      var position = 0.0;
      for (int i = 0; i < Items.Count; i++)
      {
        var pivotItem = ((PivotItem)Items[i]);
        var widthOfItem = pivotItem.ActualWidth;
        if (e.HorizontalOffset <= (position + widthOfItem - 1))
        {
          selectedItem = pivotItem;
          if (headers.SelectedItem != selectedItem)
          {
            headers.SelectedItem = selectedItem;

            internalIndex = i;
            SelectedIndex = i;

            RaiseEvent(new RoutedEventArgs(SelectionChangedEvent));
          }
          break;
        }
        position += widthOfItem;
      }

      IsManualScrolling = false;
    }