Displayalert 未显示在 IOS .net Maui 的 MopupServices 弹出页面上

问题描述 投票:0回答:1

下面的代码没有在 iOS 的弹出页面上显示显示警报。 在android中它可以正常工作。 我正在使用

Mopups.Pages.PopupPage
我正在使用 mvvm。

<?xml version="1.0" encoding="utf-8" ?>
<pages:PopupPage
xmlns:pages="clr-namespace:Mopups.Pages;assembly=Mopups" 
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:animations="clr-namespace:Mopups.Animations;assembly=Mopups"
xmlns:ffimage="clr-namespace:FFImageLoading.Maui;assembly=FFImageLoading.Maui"
xmlns:FFImgLoad="clr-namespace:FFImageLoading.Maui;assembly=FFImageLoading.Maui"
x:Class="Gaibo.Pages.CostPopupPage"
BackgroundColor="#80000000"
>
   <pages:PopupPage.Animation>
    <animations:ScaleAnimation
    PositionIn="Center"
    PositionOut="Center"
   ScaleIn=".7"
    ScaleOut="0.7"
       
 EasingIn="Linear"/>
</pages:PopupPage.Animation>
<StackLayout HorizontalOptions="CenterAndExpand" Margin="10"
         VerticalOptions="CenterAndExpand">

   
            <Button Grid.Row="3" CornerRadius="20" Padding="0" Text="Submit" VerticalOptions="CenterAndExpand" HeightRequest="45" Style="{StaticResource AllSubmitBtnStyle}" Command="{Binding SubmitCostCommand}"/>
       
</StackLayout>
</pages:PopupPage>

SubmitCostCommand 命令的代码

public class CampaignDetailsViewModel
{
   private async Task SubmitCostCommandClicked()
   {

    await App.Current.MainPage.DisplayAlert("", " Thank you for submitting Post Social Link/s.", "Ok");

   }
}

在cs文件中

public CostPopupPage (CampaignDetailslstData CampaignData)
{
     InitializeComponent();
    var vm = new CampaignDetailsViewModel();
}
ios .net popup maui
1个回答
0
投票

这是 Mopups 的已知问题。为了在 mopup 顶部显示警报,您需要从 mopup 页面本身而不是主页调用警报。

private async Task SubmitCostCommandClicked()
{

    var topPage = Mopups.Services.MopupService.Instance.PopupStack[^1];
        await topPage.DisplayAlert("Confirm", "Are you sure you want to cancel?", "Yes", "No")

}
© www.soinside.com 2019 - 2024. All rights reserved.