3

I just got started with an app for WP8.1, and encounter a problem with intercepting touch move events while leaving the original event treatment in place.

What I want to do is the following:

  • I have a ListView in a StackPanel in a ScrollViewer in a Grid. The ScrollViewer handles vertical scrolling of the StackPanel/ListView.
  • Whenever a horizontal touch move appears, I'd like to get a notification so I can adjust some ui element's position based on the horizontal movement.

Sounds simple enough, but any way I tried seems to cancel the original touch move treatment by the ScrollViewer, so the vertical scrolling is not working anymore. I'd really hate to implement the whole scrolling behavior myself ...

I tried already:

  • Putting a ManipulationMode="TranslationX" ManipulationDelta="handleXTranslation" on the ScrollViewer. The handelXTranslation handler is never called for whatever reason.
  • Putting the same Manipulation information on the ListView - now the handler gets called (and all handlers of the parent ui elements), but the ScrollViewer is not handling the scrolling anymore, probably because the ListView is not propagating the event to its parents anymore.
  • Adding a general touch handler to the xaml class when it is loaded. Same problem - either it is not called, and if it is called the scrolling of the ScrollViewer is not done anymore.

The XAML code looks like this (stripped of some data):

<Grid x:Name="LayoutRoot" Background="Transparent" ManipulationMode="TranslationX" ManipulationDelta="gridTranslationX">
    <ScrollViewer x:Name="ScrollViewer" ManipulationMode="TranslationX" ManipulationDelta="scrollViewerTranslationX">
        <StackPanel x:Name="StackPanel" Orientation="Horizontal" ManipulationMode="TranslationX" ManipulationDelta="scrollViewerTranslationX">
            <ListView x:Name="ListView" ManipulationMode="TranslationX" ManipulationDelta="scrollViewerTranslationX">
            </ListView>
        </StackPanel>
    </ScrollViewer>
</Grid>

And the handlers I tried to install in code look like this:

this.AddHandler(UIElement.ManipulationDeltaEvent, new ManipulationDeltaEventHandler(genericDeltaHandler), true);
ListView.PointerMoved += new PointerEventHandler(pointerEvent);

Is there any way to just observe the manipulation events without disturbing their normal treatment?

TheEye
  • 9,280
  • 2
  • 42
  • 58

1 Answers1

2

Sometimes it helps to talk about it ;-) ...

The answer was indeed as simple as adding the System value to the ManipulationMode on the ListView:

<ListView x:Name="ListView" ManipulationMode="TranslateX,System" ManipulationDelta="translationX">
TheEye
  • 9,280
  • 2
  • 42
  • 58