仅在屏幕的一部分上显示模态页面

ecc*_*cco 7 modal-dialog toolbar xamarin xamarin.forms

我正在使用 Xamarin.Forms 开发 iPad 应用程序。我希望我的设置页面是模态的,因此它像弹出窗口一样位于上一页上。

我一直在尝试我能找到的所有解决方案,其中大多数似乎建议我通过按钮调用它:

await Navigation.PushModalAsync(ModalSettingsPage);
Run Code Online (Sandbox Code Playgroud)

当我使用它时会发生什么情况是我的设置页面作为模式页面从下面进入,而不是作为弹出窗口,它覆盖了整个屏幕。

这是我当前的代码:

 //Setup button (action bar)
            ToolbarItems.Add(new ToolbarItem
            {
                // Text = "Setup",
                Icon = "settings1.png",
                Order = ToolbarItemOrder.Default,
                Command = new Command(() => Navigation.PushModalAsync(new ModalSettingsPage())) //Action to perfome on click , open modal view
            });
Run Code Online (Sandbox Code Playgroud)

另外,现在有人有什么好方法来定位 ToolbarItems 吗?我有两个项目并且希望每个项目都位于每一侧,但默认情况下它们都位于右侧。

Hut*_*wer 5

随着 Forms(目前是 4.5.0)的发展,推送一个非全屏的 modalpage 现在变得很简单。在您的 xaml 内容页面的代码隐藏中使用以下内容:

using Xamarin.Forms;
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;

namespace YourAppWithAModalPage
{
    public class ModalPage : ContentPage
    {
        public ModalPage()
        {
            // iOS Solution for a ModalPage (popup) which is not fullscreen
            On<iOS>().SetModalPresentationStyle(UIModalPresentationStyle.FormSheet);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)


the*_*ohn 2

表单中没有任何预先制作的内容可以为您提供我认为您想要的弹出窗口。相反,您必须创建此解决方案或使用第三方解决方案。例如,这里是一个可能适合您的“弹出”实现。