view Messaging/Common/Xaml/XamlHelper.cs @ 85:4863009a2edf

renamed bugs to todo
author Steven Hollidge <stevenhollidge@hotmail.com>
date Tue, 24 Apr 2012 00:52:39 +0100
parents 96fdf58e05b4
children
line wrap: on
line source

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();
            }
        }
    }
}