Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Listbox with touch inertia pulls down entire window

I have a full screen WPF application built for a touch monitor, and I have some Listboxs on the main screen.

When I flick the 'Listbox' it scrolls fine, but when it gets to the end of the list, the entire application gets pulled down from the top of the screen, can I stop this behavior somehow?

Has anyone else seen this?

like image 842
Mark Avatar asked Dec 22 '10 02:12

Mark


1 Answers

Yes, that default behaviour of the ListBox (or rather, the ScrollViewer inside the default ListBox template) is weird - when I first came across it, I thought it must be a practical joke. In fact, it's really hard to find any documentation about it - but it is briefly mentioned here:

The ManipulationBoundaryFeedback event enables applications or components to provide visual feedback when an object hits a boundary. For example, the Window class handles the ManipulationBoundaryFeedback event to cause the window to slightly move when its edge is encountered.

So, a way around it is to handle ManipulationBoundaryFeedback on the ListBox, and set Handled to true:

<ListBox ManipulationBoundaryFeedback="OnManipulationBoundaryFeedback">            
  // ...
</ListBox>

Code-behind:

private void OnManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e)
{
    e.Handled  = true;
}
like image 57
gstercken Avatar answered Sep 26 '22 23:09

gstercken