27
|
1 using System.Windows;
|
|
2 using System.Windows.Controls;
|
|
3
|
|
4 namespace Common.Xaml
|
|
5 {
|
|
6 public static class XamlHelper
|
|
7 {
|
|
8 public static bool GetAutoScroll(DependencyObject obj)
|
|
9 {
|
|
10 return (bool) obj.GetValue(AutoScrollProperty);
|
|
11 }
|
|
12
|
|
13 public static void SetAutoScroll(DependencyObject obj, bool value)
|
|
14 {
|
|
15 obj.SetValue(AutoScrollProperty, value);
|
|
16 }
|
|
17
|
|
18 public static readonly DependencyProperty AutoScrollProperty =
|
|
19 DependencyProperty.RegisterAttached("AutoScroll",
|
|
20 typeof(bool),
|
|
21 typeof(XamlHelper),
|
|
22 new PropertyMetadata(false, AutoScrollPropertyChanged));
|
|
23
|
|
24 private static void AutoScrollPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
25 {
|
|
26 var scrollViewer = d as ScrollViewer;
|
|
27
|
|
28 if (scrollViewer != null && (bool)e.NewValue)
|
|
29 {
|
|
30 scrollViewer.ScrollToBottom();
|
|
31 }
|
|
32 }
|
|
33 }
|
|
34 }
|