【问题标题】:Close HamburgerMenu with slide gesture使用滑动手势关闭 HamburgerMenu
【发布时间】:2018-02-06 19:05:24
【问题描述】:

我正在尝试实现一个滑动手势来打开/关闭hamburguer menu control,但我无法使用版本 1.5.1 的控件关闭菜单。在 1.4.1 版本中,我以这种方式关闭菜单:

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

但是在 1.5.1 版中,列表视图占据了控件中的所有空间,并且“OnPaneGridManipulationCompleted”不会被触发...请问有什么想法吗?

【问题讨论】:

    标签: c# uwp windows-10-mobile windows-community-toolkit


    【解决方案1】:

    您可以尝试在ListView 的内部ScrollViewer 上将HorizontalScrollModeVerticalScrollMode 设置为Disabled 以让触摸输入绕过它。

    由于HorizontalScrollMode 的默认值已经是Disabled。您只需要手动设置VerticalScrollMode,如下所示

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

    副作用是您不能再垂直滚动ListView。但一般来说,无论如何你都不会想要那个(糟糕的设计)。

    您可能还对我的this answer 感兴趣。 :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多