下面的代码没有在 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();
}
这是 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")
}