Tuesday 23 July 2013

Dragging a ListView control in a fullscreen WPF touch app causes the whole window to shift

I recently had a bug with the ListView control in WPF where I had a ContentControl using a ScrollViewer with the ItemsPresenter inside of it. When using touch, and navigating through the items, the whole window would shift when you reach the end of the list, which then allowed the user to access the underlying Windows shell.

The cause of this is due to a potential bug in the ScrollViewer control, where the UIElement.ManipulationBoundaryFeedback event is fired, and is not handled by the ListView. As this is a routed event, it continues up the chain and eventually reaches the Window control, which then handles the event and results in an animation of the entire window.

MSDN states:
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.

The fix (or hack) for this, is to hook in to the event and handle the event, so that it does not bubble up to the Window control.

No comments:

Post a Comment