diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.Touch/Controls/LightTouchScrollViewer.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.Touch/Controls/LightTouchScrollViewer.cs | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchScrollViewer.cs b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchScrollViewer.cs index 37fcac391..d1ece3f34 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/LightTouchScrollViewer.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/LightTouchScrollViewer.cs @@ -283,6 +283,49 @@ namespace Tango.Touch.Controls #endregion + #region Attached Properties + + #region Prevent Scroll + + /// <summary> + /// The prevent scroll property + /// </summary> + public static readonly DependencyProperty PreventScrollProperty = + DependencyProperty.RegisterAttached("PreventScroll", + typeof(bool), typeof(LightTouchScrollViewer), + new FrameworkPropertyMetadata(false)); + + /// <summary> + /// Sets the PreventScroll attached property. + /// </summary> + /// <param name="element">The element.</param> + /// <param name="value">if set to <c>true</c> [value].</param> + public static void SetPreventScroll(FrameworkElement element, bool value) + { + element.SetValue(PreventScrollProperty, value); + } + + /// <summary> + /// Gets the PreventScroll attached property. + /// </summary> + /// <param name="element">The element.</param> + /// <returns></returns> + public static bool GetPreventScroll(FrameworkElement element) + { + if (element != null) + { + return (bool)element.GetValue(PreventScrollProperty); + } + else + { + return false; + } + } + + #endregion + + #endregion + #region Touch / Mouse Handlers /// <summary> @@ -297,6 +340,20 @@ namespace Tango.Touch.Controls return; } + var element = e.OriginalSource as FrameworkElement; + + if (element != null) + { + if (element.FindAncestor<LightTouchScrollViewer>() != this) + { + return; + } + + if (GetPreventScroll(element)) return; + var parentPreventScroll = element.FindAncestor((x) => GetPreventScroll(x as FrameworkElement)); + if (parentPreventScroll != null) return; + } + _mouse_down_location = new Point(e.Location.X, e.Location.Y - _grid_content.Margin.Top); IsMouseTouchDown = true; } |
