Test Automation for Micro Focus UFT: Windows Forms
Test Automation for Micro Focus UFT: WPF
Test Automation for IBM RFT: Windows Forms
Indigo.Design Desktop
Collaborative prototyping and remote usability testing for UX & usability professionals
Indigo.Design
A Unified Platform for Visual Design, UX Prototyping, Code Generation, and App Development
Reveal Embedded
Accelerate your time to market with powerful, beautiful dashboards into your apps
Reveal App
Empower everyone in your organization to use data to make smarter business decisions
Your Privacy Matters
: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use.
Cookie Policy
Hello,
I am new to Infragistics and I like the tools and widgets you have.
I am using the XamDataGrid for my TouchPad. I want to gain access to the grid part as a scrollviewer, so that I can integrate my kinetic scrolling actions (dependency properties) for scrollviewer.
Below is my class for Kinetic Scrolling
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Threading;
namespace ScrollableArea
public class KineticBehaviour
#region Friction
/// <summary>
/// Friction Attached Dependency Property
/// </summary>
public static readonly DependencyProperty FrictionProperty =
DependencyProperty.RegisterAttached("Friction", typeof(double), typeof(KineticBehaviour),
new FrameworkPropertyMetadata((double)0.95));
/// <summary>
/// Gets the Friction property. This dependency property
/// indicates ....
/// </summary>
public static double GetFriction(DependencyObject d)
return (double)d.GetValue(FrictionProperty);
/// <summary>
/// Sets the Friction property. This dependency property
/// indicates ....
/// </summary>
public static void SetFriction(DependencyObject d, double value)
d.SetValue(FrictionProperty, value);
#endregion
#region ScrollStartPoint
/// <summary>
/// ScrollStartPoint Attached Dependency Property
/// </summary>
private static readonly DependencyProperty ScrollStartPointProperty =
DependencyProperty.RegisterAttached("ScrollStartPoint", typeof(Point), typeof(KineticBehaviour),
new FrameworkPropertyMetadata((Point)new Point()));
/// <summary>
/// Gets the ScrollStartPoint property. This dependency property
/// indicates ....
/// </summary>
private static Point GetScrollStartPoint(DependencyObject d)
return (Point)d.GetValue(ScrollStartPointProperty);
/// <summary>
/// Sets the ScrollStartPoint property. This dependency property
/// indicates ....
/// </summary>
private static void SetScrollStartPoint(DependencyObject d, Point value)
d.SetValue(ScrollStartPointProperty, value);
#endregion
#region ScrollStartOffset
/// <summary>
/// ScrollStartOffset Attached Dependency Property
/// </summary>
private static readonly DependencyProperty ScrollStartOffsetProperty =
DependencyProperty.RegisterAttached("ScrollStartOffset", typeof(Point), typeof(KineticBehaviour),
new FrameworkPropertyMetadata((Point)new Point()));
/// <summary>
/// Gets the ScrollStartOffset property. This dependency property
/// indicates ....
/// </summary>
private static Point GetScrollStartOffset(DependencyObject d)
return (Point)d.GetValue(ScrollStartOffsetProperty);
/// <summary>
/// Sets the ScrollStartOffset property. This dependency property
/// indicates ....
/// </summary>
private static void SetScrollStartOffset(DependencyObject d, Point value)
d.SetValue(ScrollStartOffsetProperty, value);
#endregion
#region InertiaProcessor
/// <summary>
/// InertiaProcessor Attached Dependency Property
/// </summary>
private static readonly DependencyProperty InertiaProcessorProperty =
DependencyProperty.RegisterAttached("InertiaProcessor", typeof(InertiaHandler), typeof(KineticBehaviour),
new FrameworkPropertyMetadata((InertiaHandler)null));
/// <summary>
/// Gets the InertiaProcessor property. This dependency property
/// indicates ....
/// </summary>
private static InertiaHandler GetInertiaProcessor(DependencyObject d)
return (InertiaHandler)d.GetValue(InertiaProcessorProperty);
/// <summary>
/// Sets the InertiaProcessor property. This dependency property
/// indicates ....
/// </summary>
private static void SetInertiaProcessor(DependencyObject d, InertiaHandler value)
d.SetValue(InertiaProcessorProperty, value);
#endregion
#region HandleKineticScrolling
/// <summary>
/// HandleKineticScrolling Attached Dependency Property
/// </summary>
public static readonly DependencyProperty HandleKineticScrollingProperty =
DependencyProperty.RegisterAttached("HandleKineticScrolling", typeof(bool),
typeof(KineticBehaviour),
new FrameworkPropertyMetadata((bool)false,
new PropertyChangedCallback(OnHandleKineticScrollingChanged)));
/// <summary>
/// Gets the HandleKineticScrolling property. This dependency property
/// indicates ....
/// </summary>
public static bool GetHandleKineticScrolling(DependencyObject d)
return (bool)d.GetValue(HandleKineticScrollingProperty);
/// <summary>
/// Sets the HandleKineticScrolling property. This dependency property
/// indicates ....
/// </summary>
public static void SetHandleKineticScrolling(DependencyObject d, bool value)
d.SetValue(HandleKineticScrollingProperty, value);
/// <summary>
/// Handles changes to the HandleKineticScrolling property.
/// </summary>
private static void OnHandleKineticScrollingChanged(DependencyObject d,
DependencyPropertyChangedEventArgs e)
ScrollViewer scoller = d as ScrollViewer;
if ((bool)e.NewValue)
scoller.MouseDown += OnMouseDown;
scoller.MouseMove += OnMouseMove;
scoller.MouseUp += OnMouseUp;
SetInertiaProcessor(scoller, new InertiaHandler(scoller));
scoller.MouseDown -= OnMouseDown;
scoller.MouseMove -= OnMouseMove;
scoller.MouseUp -= OnMouseUp;
var inertia = GetInertiaProcessor(scoller);
if (inertia != null)
inertia.Dispose();
#endregion
#region Mouse Events
private static void OnMouseDown(object sender, MouseButtonEventArgs e)
var scrollViewer = (ScrollViewer)sender;
if (scrollViewer.IsMouseOver)
// Save starting point, used later when determining how much to scroll.
SetScrollStartPoint(scrollViewer, e.GetPosition(scrollViewer));
SetScrollStartOffset(scrollViewer, new
Point(scrollViewer.HorizontalOffset, scrollViewer.VerticalOffset));
scrollViewer.CaptureMouse();
private static void OnMouseMove(object sender, MouseEventArgs e)
var scrollViewer = (ScrollViewer)sender;
if (scrollViewer.IsMouseCaptured)
Point currentPoint = e.GetPosition(scrollViewer);
var scrollStartPoint = GetScrollStartPoint(scrollViewer);
// Determine the new amount to scroll.
Point delta = new Point(scrollStartPoint.X - currentPoint.X,
scrollStartPoint.Y - currentPoint.Y);
var scrollStartOffset = GetScrollStartOffset(scrollViewer);
Point scrollTarget = new Point(scrollStartOffset.X + delta.X,
scrollStartOffset.Y + delta.Y);
var inertiaProcessor = GetInertiaProcessor(scrollViewer);
if (inertiaProcessor != null)
inertiaProcessor.ScrollTarget = scrollTarget;
// Scroll to the new position.
scrollViewer.ScrollToHorizontalOffset(scrollTarget.X);
scrollViewer.ScrollToVerticalOffset(scrollTarget.Y);
private static void OnMouseUp(object sender, MouseButtonEventArgs e)
var scrollViewer = (ScrollViewer)sender;
if (scrollViewer.IsMouseCaptured)
scrollViewer.ReleaseMouseCapture();
#endregion
#region Inertia Stuff
/// <summary>
/// Handles the inertia
/// </summary>
class InertiaHandler : IDisposable
private Point previousPoint;
private Vector velocity;
ScrollViewer scroller;
DispatcherTimer animationTimer;
private Point scrollTarget;
public Point ScrollTarget {
get { return scrollTarget; }
set { scrollTarget = value; } }
public InertiaHandler(ScrollViewer scroller)
this.scroller = scroller;
animationTimer = new DispatcherTimer();
animationTimer.Interval = new TimeSpan(0, 0, 0, 0, 20);
animationTimer.Tick += new EventHandler(HandleWorldTimerTick);
animationTimer.Start();
private void HandleWorldTimerTick(object sender, EventArgs e)
if (scroller.IsMouseCaptured)
Point currentPoint = Mouse.GetPosition(scroller);
velocity = previousPoint - currentPoint;
previousPoint = currentPoint;
if (velocity.Length > 1)
scroller.ScrollToHorizontalOffset(ScrollTarget.X);
scroller.ScrollToVerticalOffset(ScrollTarget.Y);
scrollTarget.X += velocity.X;
scrollTarget.Y += velocity.Y;
velocity *= KineticBehaviour.GetFriction(scroller);
#region IDisposable Members
public void Dispose()
animationTimer.Stop();
#endregion
#endregion
And I use the kinetic scrolling property as
<ScrollViewer x:Name="ScrollViewer" local:KineticBehaviour.HandleKineticScrolling="True" local:KineticBehaviour.Friction="1" >
I want to use XamDataGrid also in the same way.
<igDP:XamDataGrid BindToSampleData="True" ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollBarVisibility="Hidden" local:KineticBehaviour.HandleKineticScrolling="True" ></igDP:XamDataGrid>
Can I do this?
Thanks,
Uday.
Hello Uday,
It has been a while since you have made your post, in case you still need support I will be glad to assist you further. I suppose the other community members can benefit from this answer as well. I have been looking through your post and I suggest you use Utilities class which originates in the Infragistics.WPF4.dll file. You can use this code:
var
sv =
Utilities
.GetDescendantFromType(xamDataGrid1,
typeof
(
ScrollBar
),
true
);
to get instance of the XamDataGrid’s ScrollBar.
Feel free to write me if you have further questions.