tarik
tarik

Reputation: 11

How to display a popup window on Xamarin

I am very new to Xamarin, so please excuse me for my simple questions.

Like the alert window on the screen, I want to open a second window that can be resized and positioned. Despite all my calls, I couldn't get it.

An absolute style div for those who know html.

Thanks in advance to friends who can give me an idea of how I can do it.

Upvotes: 1

Views: 2860

Answers (1)

Mateus Wolkmer
Mateus Wolkmer

Reputation: 735

I think what you're looking for is a "Popup". It can be done by hand, but I recommend using a library like this one. It lets you customize your Popups however you want by creating custom pages for them, like this:

<?xml version="1.0" encoding="utf-8" ?>
<pages:PopupPage 
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
    xmlns:animations="clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup"
    x:Class="MyProject.MyPopupPage">
    <!--You can set an animation in the xaml file or in the csharp code behind-->
    <pages:PopupPage.Animation>
        <animations:ScaleAnimation 
            PositionIn="Center"
            PositionOut="Center"
            ScaleIn="1.2"
            ScaleOut="0.8"
            DurationIn="400"
            DurationOut="300"
            EasingIn="SinOut"
            EasingOut="SinIn"
            HasBackgroundAnimation="True"/>
    </pages:PopupPage.Animation>
    <!--You can use any elements here which are extended from Xamarin.Forms.View-->
    <StackLayout 
        VerticalOptions="Center" 
        HorizontalOptions="Center" 
        Padding="20, 20, 20, 20">
        <Label
            Text="Test"/>
    </StackLayout>
</pages:PopupPage>

If you want Popups that cover the whole screen, you can use modal pages, which are built into Xamarin. Check it here.

Upvotes: 1

Related Questions