Close HamburgerMenu with slide gesture

46 views Asked by At

I'm trying to implement a slide gesture to open/close the hamburguer menu control, but I'm having trouble closing the menu with version 1.5.1 of the control. With version 1.4.1 I close the menu this way:

var paneGrid = HamburgerMenu.FindDescendantByName("PaneGrid") as Grid; 
paneGrid.ManipulationMode = ManipulationModes.TranslateX; 
paneGrid.ManipulationCompleted += OnPaneGridManipulationCompleted;

private void OnPaneGridManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e) { 
    if (e.Cumulative.Translation.X < -50) { 
        HamburgerMenu.IsPaneOpen = false; 
    } 
}

But with version 1.5.1 the listviews take all space in the control and "OnPaneGridManipulationCompleted" does not get fired... any ideas please?

1

There are 1 answers

0
Justin XL On BEST ANSWER

You can try setting both HorizontalScrollMode and VerticalScrollMode to Disabled on the ListView's inner ScrollViewer to let touch input bypass it.

Since the default value of HorizontalScrollMode is already Disabled. You just need to manually set the VerticalScrollMode as below

if (HamburgerMenuControl.FindDescendantByName("ButtonsListView") is ListView listView)
{
    ScrollViewer.SetVerticalScrollMode(listView, ScrollMode.Disabled);
}

The side effect is that you can no longer scroll the ListView vertically. But generally you wouldn't want that(bad design) anyway.

You might also be interested in this answer of mine. :)