【问题标题】:Xamarin side menu tap issueXamarin 侧边菜单点击问题
【发布时间】:2017-06-08 17:56:32
【问题描述】:

我使用带有侧边菜单see this url 的 Xamarin 表单开发了一个应用程序。
但是我不能在我当前的项目中使用它,所以我为侧边菜单制作了我的自定义组件。

当我点击侧边菜单的范围时如何实现隐藏菜单的功能?

【问题讨论】:

    标签: xamarin.ios xamarin.forms


    【解决方案1】:

    如果没有看到您的代码,很难为您提供任何帮助,但通常我会通过添加ContentView 来解决此问题,该ContentView 会在您打开菜单时覆盖屏幕。菜单将显示在ContentView 的顶部。然后将TapGestureRecognizer 添加到ContentView,单击时会关闭菜单。

    您可以为ContentView 添加一些颜色,但使其不透明,使其透明,类似于这种颜色:#74787878

    ContentView backgroundView = new ContentView {
        BackgroundColor   = Color.FromHex("#74787878"),
        HorizontalOptions = LayoutOptions.FillAndExpand,
        VerticalOptions   = LayoutOptions.FillAndExpand,
        Content           = //Your menu
    }
    
    backgroundView.GestureRecognizers.Add(new TapGestureRecognizer {
        Command = new Command(() => {
            //Remove the background and hide the menu
        })
    });
    

    【讨论】:

      猜你喜欢
      • 2016-04-13
      • 2019-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-14
      • 1970-01-01
      相关资源
      最近更新 更多