Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xaml 使用xamarin滑入滑出_Xaml_Xamarin_Xamarin.forms - Fatal编程技术网

Xaml 使用xamarin滑入滑出

Xaml 使用xamarin滑入滑出,xaml,xamarin,xamarin.forms,Xaml,Xamarin,Xamarin.forms,我正在尝试实现这种设计,如我的页面上的图所示,如何在Xamarin.forms中实现这一点,主要是在共享项目中。因为我试图通过特定于平台的操作来降低复杂性 我甚至试过用这个。 但问题是,当菜单打开时,我无法在菜单中滑动,即在触摸页面后,我希望菜单隐藏,但不会发生。我们需要手动拖出它来关闭它 所以,请让我知道如何做到这一点 谢谢 您是否希望像下面的GIF一样实现它。 如果是这样,当您使用SlideMenu时,您应该创建一个从MenuContainerPage继承的新视图,如下代码所示 这是我的演

我正在尝试实现这种设计,如我的页面上的图所示,如何在Xamarin.forms中实现这一点,主要是在共享项目中。因为我试图通过特定于平台的操作来降低复杂性

我甚至试过用这个。 但问题是,当菜单打开时,我无法在菜单中滑动,即在触摸页面后,我希望菜单隐藏,但不会发生。我们需要手动拖出它来关闭它

所以,请让我知道如何做到这一点

谢谢

您是否希望像下面的GIF一样实现它。

如果是这样,当您使用SlideMenu时,您应该创建一个从MenuContainerPage继承的新视图,如下代码所示

这是我的演示,你可以参考一下。

根据您的描述,我修改了代码,有一个GIF

单击ImageButton时,应将此方法称为this.HideMenu

QuickInnerMenuPage的代码

有QuickInnerMenuView的代码


谢谢你的回复,但我也用同样的方式。我使用的不是slideview中的图像,而是imagebutton,当我单击任何按钮时,会出现一个弹出窗口,并且slideview应该被隐藏。Lu-MSFT嗨,我还有一件事要问你。如果我想让滑梯垂直,但在左边。它是否可能像它一样从上到下,但我希望它在左边。你能把它标记为答案吗?它将帮助其他有类似问题的人
    public class QuickInnerMenuPage: MenuContainerPage
{
    public QuickInnerMenuPage()
    {
        Content = new StackLayout
        {
            VerticalOptions = LayoutOptions.Center,
            HorizontalOptions = LayoutOptions.Center,
            Children = {
              new Label(){Text="1222"}
            }
        };

        this.SlideMenu = new QuickInnerMenuView(MenuOrientation.RightToLeft);
    }
}
  public QuickInnerMenuPage()
    {
        Content = new StackLayout
        {
            VerticalOptions = LayoutOptions.Center,
            HorizontalOptions = LayoutOptions.Center,
            Children = {
              new Label(){Text="1222"}
            }
        };

        this.SlideMenu = new QuickInnerMenuView(MenuOrientation.RightToLeft);

        QuickInnerMenuView.ib.Clicked += (o, e) =>
        {

            this.HideMenu();
        };


    }
}
    public class QuickInnerMenuView : SlideMenuView
{
    public static ImageButton ib;
    public QuickInnerMenuView (MenuOrientation orientation)
    {
         ib = new ImageButton
        {
            Source = "Happy.png",
            WidthRequest = 25,
            HeightRequest = 25,
        };

        var mainLayout = new StackLayout {
            Spacing = 15,
            Children = {
                ib,
                new ImageButton {
                    Source = "Home.png",
                    WidthRequest = 25,
                    HeightRequest = 25,
                },
                new ImageButton {
                    Source = "MessageFilled.png",
                    WidthRequest = 25,
                    HeightRequest = 25,
                },
                new ImageButton {
                    Source = "Settings.png",
                    WidthRequest = 25,
                    HeightRequest = 25,
                },
            }
        };
        // In this case the IsFullScreen must set false
        this.IsFullScreen = false;
        this.BackgroundViewColor = Color.Transparent;

        // You must set BackgroundColor, 
        // and you cannot put another layout with background color cover the whole View
        // otherwise, it cannot be dragged on Android
        this.BackgroundColor = Color.FromHex ("#C82630");
        this.MenuOrientations = orientation;
        if (orientation == MenuOrientation.BottomToTop) {
            mainLayout.Orientation = StackOrientation.Vertical;
            mainLayout.Children.Insert (0, new Image {
                Source = "DoubleUp.png",
                WidthRequest = 25,
                HeightRequest = 25,
            });
            mainLayout.Padding = new Thickness (0, 5);
            // In this case, you must set both WidthRequest and HeightRequest.
            this.WidthRequest = 50; 
            this.HeightRequest = 200;

            // A little bigger then DoubleUp.png image size, used for user drag it.
            this.DraggerButtonHeight = 30;

            // In this menu direction you must set LeftMargin.
            this.LeftMargin = 100;

        }