本文整理汇总了C#中System.Windows.Controls.ScrollViewer.ScrollToBottom方法的典型用法代码示例。如果您正苦于以下问题:C# ScrollViewer.ScrollToBottom方法的具体用法?C# ScrollViewer.ScrollToBottom怎么用?C# ScrollViewer.ScrollToBottom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.ScrollViewer
的用法示例。
在下文中一共展示了ScrollViewer.ScrollToBottom方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnApplyTemplate
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_scrollViewer = GetTemplateChild("scrollViewer") as ScrollViewer;
if(_scrollViewer == null)
return;
_scrollViewer.ScrollToBottom();
_scrollViewer.ScrollChanged += OnScrollChanged;
}
示例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: AddLogText
/// <summary>
/// Update wallet log.
/// </summary>
/// <param name="text"></param>
/// <param name="logLines"></param>
/// <param name="textBox"></param>
/// <param name="scrollViewer"></param>
private void AddLogText(string text, IList<string> logLines, TextBox textBox, ScrollViewer scrollViewer)
{
while (logLines.Count >= 50)
{
logLines.RemoveAt(0);
}
logLines.Add(text);
if (logLines.Count == 1)
{
textBox.Text = logLines.First();
}
else
{
textBox.Text = logLines.Aggregate((l1, l2) => l1 + Environment.NewLine + l2);
textBox.AppendText(Environment.NewLine); // Hack: make sure scroll to bottom works
scrollViewer.ScrollToBottom();
}
}