using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace HistoryDLL
{
public class ScrollViewerUtilities
{
#region HorizontalOffset
///
/// HorizontalOffset Attached Dependency Property
///
public static DependencyProperty HorizontalOffsetProperty =
DependencyProperty.RegisterAttached("HorizontalOffset", typeof(double), typeof(ScrollViewerUtilities),
new FrameworkPropertyMetadata(ScrollViewerUtilitieschange(),
new PropertyChangedCallback(OnHorizontalOffsetChanged)));
public static bool UseMotionStop = false;
private static object ScrollViewerUtilitieschange()
{
double result = (double)(int.Parse(System.Windows.Application.Current.Properties["ReturnPos"].ToString()));
return result;
}
///
/// Gets the HorizontalOffset property. This dependency property
/// indicates ....
///
public static double GetHorizontalOffset(DependencyObject d)
{
return (double)d.GetValue(HorizontalOffsetProperty);
}
///
/// Sets the HorizontalOffset property. This dependency property
/// indicates ....
///
public static void SetHorizontalOffset(DependencyObject d, double value)
{
d.SetValue(HorizontalOffsetProperty, value);
}
///
/// Handles changes to the HorizontalOffset property.
///
private static void OnHorizontalOffsetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (!UseMotionStop)
{
var viewer = (ScrollViewer)d;
viewer.ScrollToHorizontalOffset((double)e.NewValue);
}
}
#endregion
#region VerticalOffset
///
/// VerticalOffset Attached Dependency Property
///
public static readonly DependencyProperty VerticalOffsetProperty =
DependencyProperty.RegisterAttached("VerticalOffset", typeof(double), typeof(ScrollViewerUtilities),
new FrameworkPropertyMetadata((double)0.0,
new PropertyChangedCallback(OnVerticalOffsetChanged)));
///
/// Gets the VerticalOffset property. This dependency property
/// indicates ....
///
public static double GetVerticalOffset(DependencyObject d)
{
return (double)d.GetValue(VerticalOffsetProperty);
}
///
/// Sets the VerticalOffset property. This dependency property
/// indicates ....
///
public static void SetVerticalOffset(DependencyObject d, double value)
{
d.SetValue(VerticalOffsetProperty, value);
}
///
/// Handles changes to the VerticalOffset property.
///
private static void OnVerticalOffsetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var viewer = (ScrollViewer)d;
viewer.ScrollToVerticalOffset((double)e.NewValue);
}
#endregion
}
}