locked
Can't figure out how to receive manipulation events from Hub control

    Question

  • I am trying to listen to the manipulation events of a Hub control. I don't want to change them. I want to animate a decorative element in response to the horizontal movement of the Hub control.

    I have tried several settings of ManipulationMode on the Hub control in XAML and code-behind. I have tried "All" "TranslateX" "System" and "System,TranslateX." I am using AddHandler in my page's Loaded event to add handlers for ManipulationStarting, ManipulationDelta, and ManipulationCompleted. I have tried adding the handlers to the page  "this.AddHandler..." and directly to the Hub control "myHubControl.AddHandler." I am sure to set handledEventsToo to true.

    Here is an example of my handler calls:

    myHubControl.AddHandler(UIElement.ManipulationDeltaEvent, new ManipulationDeltaEventHandler(this.Hub_ManipulationDelta), true);

    In all these combinations of things, the only event that ever gets fired is ManipulationStarting. The other two never get fired even though the Hub control is clearly being manipulated.

    Does anyone have any suggestions?

    Thank you!


    Thaine Norris


    • Edited by dtnorris Wednesday, May 7, 2014 3:30 PM
    Wednesday, May 7, 2014 3:26 PM

Answers

  • Once the Hub control's ScrollViewer has started scrolling it will capture all of the pointer messages.

    I discussed this previously in my blog entry Where did all my gestures go? 

    If you're trying to respond to the control's movement then you'll probably be better off binding to the scroll position than trying to trap the input. That way the same code will work for all input modes (touch, stylus, mouse, and keyboard)

    --Rob

    • Marked as answer by dtnorris Thursday, May 8, 2014 2:19 PM
    Thursday, May 8, 2014 2:00 PM
    Owner

All replies

  • Hi Thaine - what manipulation are you attempting to capture on the Hub control?  I'll try it and see what happens on my machine.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, May 8, 2014 12:54 PM
    Moderator
  • Once the Hub control's ScrollViewer has started scrolling it will capture all of the pointer messages.

    I discussed this previously in my blog entry Where did all my gestures go? 

    If you're trying to respond to the control's movement then you'll probably be better off binding to the scroll position than trying to trap the input. That way the same code will work for all input modes (touch, stylus, mouse, and keyboard)

    --Rob

    • Marked as answer by dtnorris Thursday, May 8, 2014 2:19 PM
    Thursday, May 8, 2014 2:00 PM
    Owner
  • Hi Rob,

    I wish I had found your blog post at first. That explains a lot.

    I hunted around quite a bit looking for a way to bind to the Hub control's ScrollViewer horizontal scroll position. Do you have a sample or can you show how that would be done? Specifically, I want to turn the horizontal value into a rotation angle for a decorative element that is displayed adjacent to the Hub control.

    Thank you!

    Thaine


    Thaine Norris

    Thursday, May 8, 2014 2:31 PM
  • Hi Rob,

    Can you point me in the right direction for how to bind to the scroll position as you suggested?

    Thank you


    Thaine Norris

    Friday, May 9, 2014 10:31 PM
  • Hi Rob,

    Can you point me in the right direction for how to do what you suggested?

    Thank you


    Thaine Norris

    Monday, May 12, 2014 5:40 PM
  • Only very generally right now: you should be able to find the ScrollViewer in the Hub's template. The ScrollViewer has a property HorizontalOffset that you should be able to bind to. You may also be able to get the effect you're looking for by handling the ScrollViewer's ViewChanging event.
    Monday, May 12, 2014 5:57 PM
    Owner