How to use Plugin.Maui.Popup
Install Plugin.Maui.Popup Plugin in your project.
https://www.nuget.org/packages/Plugin.Maui.Popup (1.0.4)
Now add xmlns:mauiPopup="clr-namespace:MauiPopup.Views;assembly=MauiPopup" this namespace in your content page.
Also replace ContentPage tag to <mauiPopup:BasePopupPage.
PopupPage.xaml
<?xml version="1.0" encoding="utf-8" ?> <mauiPopup:BasePopupPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:mauiPopup="clr-namespace:MauiPopup.Views;assembly=MauiPopup" x:Class="MauiPopupDemo.PopupPage" Title="PopupPage"> <VerticalStackLayout> <Label Text="Welcome to .NET MAUI!" VerticalOptions="Center" HorizontalOptions="Center" /> </VerticalStackLayout> </mauiPopup:BasePopupPage>
using MauiPopup.Views; namespace MauiPopupDemo; public partial class PopupPage : BasePopupPage { public PopupPage() { InitializeComponent(); } }
MauiPopup.PopupAction.DisplayPopup(new PopupPage());How to close Popup
MauiPopup.PopupAction.ClosePopup();
Display Popup that returning string value
string result = await MauiPopup.PopupAction.DisplayPopup(new PopupPage());
Now Pass String Value on ClosePopup Method
PopupAction.ClosePopup("hi");
Display Popup that returning other then string value
bool result = await MauiPopup.PopupAction.DisplayPopup<boo>(new PopupPage());
Now Pass Bool Value on ClosePopup Method
PopupAction.ClosePopup(true);
Pass Any Type of value in this method.
PopupAction.ClosePopup("hi");To Get String Value
To Get Other Type of Valuestring result = await MauiPopup.PopupAction.DisplayPopup(new PopupPage());
string result = await MauiPopup.PopupAction.DisplayPopup<int>(new PopupPage()); string result = await MauiPopup.PopupAction.DisplayPopup<bool>(new PopupPage()); string result = await MauiPopup.PopupAction.DisplayPopup<AnyTypeOfClass>(new PopupPage());
Implementation Video
Is it possible to pass data to the pop up?
ReplyDelete