none
关于 手势 水平移动和PointerPressed PointerReleased 事件的问题 RRS feed

  • 问题

  • 我记得有个帖子 Bob Bao 说 手势水平移动和Pointer 可以响应同一个PointerPressed, PointerReleased事件。

    但如果 用手势点击下 一直拖拽到 另外一个点。

    手势点击下的瞬间 同时响应PointerPressed, PointerReleas 两个事件

    当放开手势后 并不响应PointerReleas 了 

    问题:如何才保证 手势的水平移动和鼠标的水平一直共同响应PointerPressed, PointerReleased事件?

     <ScrollViewer Name="MyScrollViewer"   Grid.Column="0"   VerticalScrollBarVisibility="Auto" PointerPressed="mygrid_PointerPressed_1" PointerReleased="mygrid_PointerReleased_1" PointerMoved="MyScrollViewer_PointerMoved_1"  ZoomMode="Enabled" MinZoomFactor="1" MaxZoomFactor="1.5" Margin="0" HorizontalScrollMode="Enabled" VerticalScrollMode="Enabled"  SizeChanged="MyScrollViewer_SizeChanged_1" ViewChanged="MyScrollViewer_ViewChanged_1" PointerWheelChanged="MyScrollViewer_PointerWheelChanged_1"   >

                    <StackPanel Orientation="Horizontal" Name="MyStackPanel"  >

                    </StackPanel>

                </ScrollViewer>

            public Point point = new Point();
            public bool CheckMove = false;
            private void mygrid_PointerPressed_1(object sender, PointerRoutedEventArgs e)
            {
                if (!checkadd)
                {
                    MyScrollViewer.ScrollToHorizontalOffset(offset1);

                }
                else
                {
                    offset1 = MyScrollViewer.HorizontalOffset;

                }

     

             
            }

            private void mygrid_PointerReleased_1(object sender, PointerRoutedEventArgs e)
            {
               Windows.UI.Input.PointerPoint pt = e.GetCurrentPoint(this.pageRoot);
                Point currentContact = pt.Position;

            }

    2012年8月9日 9:30

答案

  • Hi,

    的确是这样,手势点击的话是能够响应PointerPressed事件和PointerReleased事件,而手势拖拽的话就只能响应PointerPressed事件。

    我认为在手势移动跟鼠标移动有比较大的区别,手势拖拽时不响应Released事件,有时候可能人们想重新排序等等想法,因为很多功能是在Released事件中触发的,但很多人在拖拽结束后可能并不想打开程序或者触发功能。

    你可以通过设置DragEnter,DragLeave,DragOver和Drop事件对手势进行特殊处理,下面是UIElement class你可以做参考:

    http://msdn.microsoft.com/en-us/library/windows/apps/br208911.aspx

    Hope this helps


    Aaron Xue [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    2012年8月10日 9:21
    版主