Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show modal page on only a portion of the screen

I am developing an iPad app using Xamarin.Forms. I would like my settingspage to be modal so it lay over the previous page like a popup.

I have been trying all solutions I could find and most of them seems to recommend me to call this from a button:

await Navigation.PushModalAsync(ModalSettingsPage);

What happens when I use it is that my settingspage comes in from below as a modal page but not as a popup, it covers the entire screen.

This is my current code:

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

Also, does anyone now if there is any good way to positions the ToolbarItems? I have two items and would like each one to be positioned at each side, but by default they are both positioned to the right.

like image 690
ecco Avatar asked Mar 29 '16 08:03

ecco


Video Answer


2 Answers

With the evolution of Forms (currently 4.5.0), it has now become simple to push a modalpage which is not fullscreen. Use the following in your code-behind of your xaml contentpage:

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);
        }
    }
}
like image 121
Hutjepower Avatar answered Oct 11 '22 13:10

Hutjepower


There is nothing pre-made in Forms to give you a popup like I think you want. Instead, you would have to create this or use a third-party solution. For example, here is a "popup" implementation that might work for you.

like image 29
therealjohn Avatar answered Oct 11 '22 13:10

therealjohn