本文整理汇总了C#中System.Windows.Controls.ScrollViewer.ScrollToTop方法的典型用法代码示例。如果您正苦于以下问题:C# ScrollViewer.ScrollToTop方法的具体用法?C# ScrollViewer.ScrollToTop怎么用?C# ScrollViewer.ScrollToTop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.ScrollViewer
的用法示例。
在下文中一共展示了ScrollViewer.ScrollToTop方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
public void Load(IPdfSource source, string password = null)
{
virtualPanel = VisualTreeHelperEx.FindChild<CustomVirtualizingPanel>(this);
scrollViewer = VisualTreeHelperEx.FindChild<ScrollViewer>(this);
virtualPanel.PageRowBounds = parent.PageRowBounds.Select(f => f.SizeIncludingOffset).ToArray();
imageProvider = new PdfImageProvider(source, parent.TotalPages,
new PageDisplaySettings(parent.GetPagesPerRow(), parent.ViewType, parent.HorizontalMargin,
parent.Rotation),
password: password);
if (parent.ZoomType == ZoomType.Fixed)
CreateNewItemsSource();
else if (parent.ZoomType == ZoomType.FitToHeight)
ZoomToHeight();
else if (parent.ZoomType == ZoomType.FitToWidth)
ZoomToWidth();
if (scrollViewer != null)
{
scrollViewer.Visibility = Visibility.Visible;
scrollViewer.ScrollToTop();
}
}
示例2: AdjustScrollPosition
/// <summary>
/// This is the command scroll adjustment code which synchronizes two ScrollViewer instances.
/// </summary>
/// <param name="sv">ScrollViewer to adjust</param>
/// <param name="e">Change in the source</param>
/// <param name="hadjust">Horizontal adjustment</param>
/// <param name="vadjust">Vertical adjustment</param>
private static void AdjustScrollPosition(ScrollViewer sv, ScrollChangedEventArgs e, double hadjust, double vadjust)
{
if (e.HorizontalChange != 0 || e.ExtentWidthChange != 0)
{
if (e.HorizontalOffset == 0)
sv.ScrollToLeftEnd();
else if (e.HorizontalOffset >= e.ExtentWidth-5)
sv.ScrollToRightEnd();
else if (e.ExtentWidth + hadjust == sv.ExtentWidth)
sv.ScrollToHorizontalOffset(e.HorizontalOffset + hadjust);
else
sv.ScrollToHorizontalOffset((sv.ExtentWidth * (e.HorizontalOffset / e.ExtentWidth)) + hadjust);
}
if (e.VerticalChange != 0 || e.ExtentHeightChange != 0)
{
if (e.VerticalOffset == 0)
sv.ScrollToTop();
else if (e.VerticalOffset >= e.ExtentHeight-5)
sv.ScrollToBottom();
else if (e.ExtentHeight + vadjust == sv.ExtentHeight)
sv.ScrollToVerticalOffset(e.VerticalOffset + vadjust);
else
sv.ScrollToVerticalOffset((sv.ExtentHeight * (e.VerticalOffset / e.ExtentHeight)) + vadjust);
}
}
示例3: ResetScrollPositions
internal static void ResetScrollPositions( ScrollViewer scrollViewer )
{
if( scrollViewer == null )
{
throw new ArgumentNullException( "scrollViewer" );
}
DataGridScrollViewer dataGridScrollViewer = scrollViewer as DataGridScrollViewer;
if( dataGridScrollViewer != null )
{
foreach( SynchronizedScrollViewer ssv in dataGridScrollViewer.SynchronizedScrollViewers )
{
ssv.ScrollToTop();
ssv.ScrollToLeftEnd();
}
}
scrollViewer.ScrollToTop();
scrollViewer.ScrollToLeftEnd();
}