public void ScrollLast() { VirtualStackPanel vsp = getPanel(); if (vsp != null) { updateHorizOffset(vsp.ExtentWidth); } }
public void ScrollFirst() { VirtualStackPanel vsp = getPanel(); if (vsp != null) { updateHorizOffset(0); } }
public void ScrollRight() { VirtualStackPanel vsp = getPanel(); if (vsp != null) { updateHorizOffset(ScrollOffset + vsp.ViewportWidth); } }
private VirtualStackPanel getPanel() { if (_scroll != null) { ItemsPresenter ip = UITools.FindVisualChild <ItemsPresenter>(this); VirtualStackPanel vsp = UITools.FindVisualChild <VirtualStackPanel>(ip); return(vsp); } return(null); }
public bool CanScrollLeft() { VirtualStackPanel vsp = getPanel(); if (vsp != null) { if (vsp.ExtentWidth < vsp.ViewportWidth) { return(false); } } return(finalOFfset > 0); }
private void updateScrollViewer() { if (_scroll != null) { ItemsPresenter ip = UITools.FindVisualChild <ItemsPresenter>(this); VirtualStackPanel vsp = UITools.FindVisualChild <VirtualStackPanel>(ip); if (vsp != null) { double itemFitInViewPort = vsp.ViewportWidth / ActualHeight; double offsetMiddle = ((vsp.ViewportWidth + ActualHeight) / 2); //double newOffset = (ChildWidth * (SelectedIndex - (itemFitInViewPort / 2))); double newOffset = (ActualHeight * (SelectedIndex + 1)) - offsetMiddle; updateHorizOffset(newOffset); } } }
private void updateHorizOffset(double offset) { VirtualStackPanel vsp = UITools.FindVisualChild <VirtualStackPanel>(this); //ppanel.Dispatcher.BeginInvoke(DispatcherPriority.Background, new ThreadStart(() => CommandManager.InvalidateRequerySuggested(); //)); finalOFfset = offset; DoubleAnimation moveAnimation = new DoubleAnimation(); moveAnimation.To = offset; bool largeChange = Math.Abs(ScrollOffset - offset) > ActualHeight; moveAnimation.Duration = new Duration(TimeSpan.FromSeconds(AutoPlay ? 0 : largeChange ? 1 : 0.5)); this.BeginAnimation(PreviewPanelBase.ScrollOffsetProperty, moveAnimation); }