locked
Thumb.PointerPressed += ThumbBottomRight_PointerPressed is not firing

    Question

  • The left mouse click button is not triggering the function but the right mouse button does.This is specific to Windows.UI.Xaml.Controls.Primitive.Thumb control. I'm using the Windows 8.1 with Latest update as of today


    • Edited by prasvenk Thursday, April 24, 2014 12:57 AM
    Thursday, April 24, 2014 12:56 AM

Answers

  • Hi Prasvenk,

    Have you tried something like:

                thumb.AddHandler(UIElement.PointerPressedEvent, new PointerEventHandler(thumb_pressed), true);
                thumb.AddHandler(UIElement.PointerReleasedEvent, new PointerEventHandler(thumb_released), true);

    As I explained before, the XAML could not pass the mouse event correctly, which is a known issue. By using my code, you should be able to fire the press and release event.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by prasvenk Tuesday, April 29, 2014 2:00 AM
    Monday, April 28, 2014 7:58 AM
    Moderator
  • It sounds like the Thumb control handles the PointerPressed events for its own use. Once the event has been handled it won't propagate further to be handled again. This is typical behavior of controls.

    Since the Grid doesn't do any pointer handling it won't mark the event as handled.

    Adding a custom event on top of the Thumb's built-in handling will need to be done carefully not to confuse your users.

    As Jamles notes, you can use AddHandler to add an event handler that can fire even if the event has already been handled.

    --Rob

    Monday, April 28, 2014 9:59 PM
    Owner

All replies

  • Hi prasvenk,

    It could be a limitation for XAML, XAML cannot route the tapped event to the methods.

    But you could do something like below, should fire the tapped event while the mouse left click:

            public MainPage()
            {
                this.InitializeComponent();
                thumb.PointerPressed += thumb_PointerPressed;
                thumb.AddHandler(UIElement.TappedEvent, new TappedEventHandler(thumb_tapped), true);
            }
    
            void thumb_PointerPressed(object sender, PointerRoutedEventArgs e)
            {
                throw new NotImplementedException();
            }
    
    
            private void thumb_tapped(object sender, TappedRoutedEventArgs e)
            {
                //implementation
            }

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by prasvenk Thursday, April 24, 2014 9:57 PM
    • Unmarked as answer by prasvenk Friday, April 25, 2014 4:49 PM
    Thursday, April 24, 2014 8:46 AM
    Moderator
  • But this looks like a bug .I want to do certain action in the press and undo that in the release .This cannot be achieved using the Tapped event. Again I can use the pressed and released in a Grid.
    • Edited by prasvenk Friday, April 25, 2014 4:51 PM
    Friday, April 25, 2014 4:51 PM
  • Hi Prasvenk,

    Have you tried something like:

                thumb.AddHandler(UIElement.PointerPressedEvent, new PointerEventHandler(thumb_pressed), true);
                thumb.AddHandler(UIElement.PointerReleasedEvent, new PointerEventHandler(thumb_released), true);

    As I explained before, the XAML could not pass the mouse event correctly, which is a known issue. By using my code, you should be able to fire the press and release event.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by prasvenk Tuesday, April 29, 2014 2:00 AM
    Monday, April 28, 2014 7:58 AM
    Moderator
  • It sounds like the Thumb control handles the PointerPressed events for its own use. Once the event has been handled it won't propagate further to be handled again. This is typical behavior of controls.

    Since the Grid doesn't do any pointer handling it won't mark the event as handled.

    Adding a custom event on top of the Thumb's built-in handling will need to be done carefully not to confuse your users.

    As Jamles notes, you can use AddHandler to add an event handler that can fire even if the event has already been handled.

    --Rob

    Monday, April 28, 2014 9:59 PM
    Owner
  • That worked, Thanks.

    But why is PointerReleased event fired in the control but not the PointerPressed?

    Tuesday, April 29, 2014 2:04 AM
  • But why is PointerReleased event fired in the control but not the PointerPressed?

    Both are fired. From the behavior you describe the Thumb control handles PointerPressed but not PointerReleased.
    Tuesday, April 29, 2014 6:05 PM
    Owner