/// <summary>
        /// A static helper method to raise the BeginDrag event on a target element.
        /// </summary>
        /// <param name="target">UIElement or ContentElement on which to raise the event</param>
        /// <param name="device">The input device that owns the drag operation.</param>
        /// <param name="dragOrigin">The origin of the drag operation relative to the input element raising the event.</param>
        /// <param name="currentPosition">The current position of the input device relative to the input element raising the event.</param>
        internal static BeginDragEventArgs RaiseBeginDragEvent(DependencyObject target, InputDevice device, Point dragOrigin, Point currentPosition)
        {
            if (target == null)
            {
                return(null);
            }

            BeginDragEventArgs args = new BeginDragEventArgs(device, dragOrigin, currentPosition);

            args.RoutedEvent = BeginDragEvent;
            RoutedEventHelper.RaiseEvent(target, args);
            return(args);
        }
示例#2
0
        private static void OnBeginDrag(object sender, BeginDragEventArgs e)
        {
            UIElement      element        = e.OriginalSource as UIElement;
            LoopingListBox loopingListBox = sender as LoopingListBox;

            if (loopingListBox != null &&
                loopingListBox.LoopPanel != null &&
                element != null)
            {
                Point origin  = element.TranslatePoint(e.DragOrigin, loopingListBox.LoopPanel);
                Point current = element.TranslatePoint(e.CurrentPosition, loopingListBox.LoopPanel);
                loopingListBox.BeginDragOperation(e.Device, origin);
                loopingListBox.UpdateDragPosition(current);
            }
        }
        /// <summary>
        /// A static helper method to raise the BeginDrag event on a target element.
        /// </summary>
        /// <param name="target">UIElement or ContentElement on which to raise the event</param>
        /// <param name="device">The input device that owns the drag operation.</param>
        /// <param name="dragOrigin">The origin of the drag operation relative to the input element raising the event.</param>
        /// <param name="currentPosition">The current position of the input device relative to the input element raising the event.</param>
        internal static BeginDragEventArgs RaiseBeginDragEvent(DependencyObject target, InputDevice device, Point dragOrigin, Point currentPosition)
        {
            if (target == null) return null;

            BeginDragEventArgs args = new BeginDragEventArgs(device, dragOrigin, currentPosition);
            args.RoutedEvent = BeginDragEvent;
            RoutedEventHelper.RaiseEvent(target, args);
            return args;
        }
        private static void OnBeginDrag(object sender, BeginDragEventArgs e)
        {
            UIElement element = e.OriginalSource as UIElement;
            LoopingListBox loopingListBox = sender as LoopingListBox;

            if (loopingListBox != null
                && loopingListBox.LoopPanel != null
                && element != null)
            {
                Point origin = element.TranslatePoint(e.DragOrigin, loopingListBox.LoopPanel);
                Point current = element.TranslatePoint(e.CurrentPosition, loopingListBox.LoopPanel);
                loopingListBox.BeginDragOperation(e.Device, origin);
                loopingListBox.UpdateDragPosition(current);
            }

            e.Handled = true;
        }