Beispiel #1
0
        /// <summary>
        /// Scroll to a selected index (with animation or not)
        /// </summary>
        internal void ScrollToSelectedIndex(PickerSelectorItem selectedItem, TimeSpan duration)
        {
            if (!templateApplied)
            {
                return;
            }

            var centerTopOffset = (this.ActualHeight / 2d) - (itemHeight) / 2d;

            var deltaOffset = centerTopOffset - selectedItem.GetVerticalPosition();

            if (Double.IsInfinity(deltaOffset) || Double.IsNaN(deltaOffset))
            {
                return;
            }

            if (duration == TimeSpan.Zero)
            {
                this.sliderVertical.Value += deltaOffset;
            }
            else
            {
                this.UpdatePositionsWithAnimationAsync(selectedItem, deltaOffset, duration);
            }
        }
        /// <summary>
        /// Scroll to a selected index (with animation or not)
        /// </summary>
        internal void ScrollToSelectedIndex(PickerSelectorItem selectedItem, TimeSpan duration)
        {
            if (!templateApplied)
                return;

            var centerTopOffset = Orientation == Orientation.Vertical
                ? (this.ActualHeight / 2d) - (itemHeight) / 2d
                : (this.ActualWidth / 2d) - (itemWidth) / 2d;

            var deltaOffset = centerTopOffset -
                              (Orientation == Orientation.Vertical
                                  ? selectedItem.GetVerticalPosition()
                                  : selectedItem.GetHorizontalPosition());

            if (Double.IsInfinity(deltaOffset) || Double.IsNaN(deltaOffset))
                return;

            if (duration == TimeSpan.Zero)
                this.internalSlider.Value += deltaOffset;
            else
                this.UpdatePositionsWithAnimationAsync(selectedItem, deltaOffset, duration);
        }