本文整理汇总了C#中System.Windows.Controls.ScrollViewer.UpdateLayout方法的典型用法代码示例。如果您正苦于以下问题:C# ScrollViewer.UpdateLayout方法的具体用法?C# ScrollViewer.UpdateLayout怎么用?C# ScrollViewer.UpdateLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.ScrollViewer
的用法示例。
在下文中一共展示了ScrollViewer.UpdateLayout方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowLog
/// <summary>
/// Shows log file in a separate child window on top
/// </summary>
public static void ShowLog()
{
var popup = new Popup();
var text = new TextBlock();
text.Width = 800;
text.TextWrapping = TextWrapping.Wrap;
try
{
text.Text = GetLogContents();
}
catch (Exception exception)
{
text.Text = string.Format("Cannot open log file, exception is\n {0}", exception.ToString());
}
var closeButton = new Button();
closeButton.Content = "Close";
closeButton.Click += (s, e) => popup.IsOpen = false;
var scroll = new ScrollViewer();
scroll.Background = new SolidColorBrush(Colors.White);
scroll.Content = text;
scroll.Height = 400;
var content = new StackPanel();
content.Children.Add(scroll);
content.Children.Add(closeButton);
popup.Child = content;
popup.IsOpen = true;
// scroll to the bottom
scroll.UpdateLayout();
scroll.ScrollToVerticalOffset(double.MaxValue);
}
示例2: AppendToActivityLog
public static void AppendToActivityLog(ScrollViewer scrollViewer, TextBlock textBlock, MessageLevelsEnum level, string text)
{
if (scrollViewer.Dispatcher.CheckAccess())
{
Run activityRun = new Run();
activityRun.Text = text;
activityRun.Foreground = GetBrushForMessageLevel(level);
textBlock.Inlines.Add(activityRun);
textBlock.Inlines.Add(new LineBreak());
//scrollViewer.ScrollToVerticalOffset(scrollViewer.ScrollableHeight + 20);
scrollViewer.UpdateLayout();
scrollViewer.ScrollToVerticalOffset(Double.MaxValue);
}
else
{
scrollViewer.Dispatcher.BeginInvoke(new AppendToActivityLogDelegate(AppendToActivityLog), scrollViewer, textBlock, level, text);
}
}