Mercurial > silverbladetech
diff Messaging/Common/Xaml/XamlHelper.cs @ 27:96fdf58e05b4
Server working with sockets and rabbitmq
author | adminsh@apollo |
---|---|
date | Wed, 21 Mar 2012 19:00:59 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Messaging/Common/Xaml/XamlHelper.cs Wed Mar 21 19:00:59 2012 +0000 @@ -0,0 +1,34 @@ +using System.Windows; +using System.Windows.Controls; + +namespace Common.Xaml +{ + public static class XamlHelper + { + public static bool GetAutoScroll(DependencyObject obj) + { + return (bool) obj.GetValue(AutoScrollProperty); + } + + public static void SetAutoScroll(DependencyObject obj, bool value) + { + obj.SetValue(AutoScrollProperty, value); + } + + public static readonly DependencyProperty AutoScrollProperty = + DependencyProperty.RegisterAttached("AutoScroll", + typeof(bool), + typeof(XamlHelper), + new PropertyMetadata(false, AutoScrollPropertyChanged)); + + private static void AutoScrollPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var scrollViewer = d as ScrollViewer; + + if (scrollViewer != null && (bool)e.NewValue) + { + scrollViewer.ScrollToBottom(); + } + } + } +}