Alias Varghese
Alias Varghese

Reputation: 2172

Adding inertia for WPF touch application listbox

I have a full screen WPF application built for a touch monitor, and I have some ListBoxes 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, But I need the inertia just for the list box not for the entire window. How I can achieve that?

Upvotes: 0

Views: 563

Answers (1)

Mohit S
Mohit S

Reputation: 14044

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;
}

Upvotes: 1

Related Questions