代码之家  ›  专栏  ›  技术社区  ›  Cabuxa.Mapache

用滑动手势关闭HamburgerMenu

  •  1
  • Cabuxa.Mapache  · 技术社区  · 8 年前

    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 回复  |  直到 8 年前
        1
  •  1
  •   Justin XL    8 年前

    您可以尝试设置两者 HorizontalScrollMode VerticalScrollMode Disabled ListView 的内部 ScrollViewer

    由于默认值为 水平滚动模式 已经是了 残废 如下所示

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

    副作用是您无法再滚动

    你可能还对 this answer 我的。:)