Xamarin.forms 如何在Xamarin窗体中关闭启动屏幕之前显示确认对话框
我正在使用针对Android和iOS的MVVMCross开发一个Xamarin.Forms应用程序,现在我需要在应用程序完全加载之前在服务器上执行一些验证,这些验证的结果需要向用户提供一个带有会议的确认对话框,并阻止他在接受或取消对话框之前继续 以下是我需要使用的模拟代码:Xamarin.forms 如何在Xamarin窗体中关闭启动屏幕之前显示确认对话框,xamarin.forms,xamarin.android,xamarin.ios,mvvmcross,Xamarin.forms,Xamarin.android,Xamarin.ios,Mvvmcross,我正在使用针对Android和iOS的MVVMCross开发一个Xamarin.Forms应用程序,现在我需要在应用程序完全加载之前在服务器上执行一些验证,这些验证的结果需要向用户提供一个带有会议的确认对话框,并阻止他在接受或取消对话框之前继续 以下是我需要使用的模拟代码: public class App : MvxApplication { public override void Initialize() { //... a lot of Dependenc
public class App : MvxApplication
{
public override void Initialize()
{
//... a lot of Dependencies registering
RegisterCustomAppStart<AppStart>();
}
}
public class AppStart : MvxAppStart
{
private readonly IMvxLog _log;
private readonly IMyApiService _apiService;
public AppStart(IMvxApplication application, IMvxNavigationService navigationService) : base(application, avigationService)
{
_log = Mvx.IoCProvider.Resolve<IMvxLog>();
_apiService = Mvx.IoCProvider.Resolve<IMyApiService>();
}
protected override Task NavigateToFirstViewModel(object hint = null)
{
//This is all the code I need to make work, all these lines are pseudo code
//Do my server side validations
var myObj = await _apiService.staticValidations();
//Here I need to validate myObj, something like:
var result = false;
if(myObj.boolValue)
{
var result = await showConfirmationDialog();
//result should contains the value depending on user's selection: if pressed cancel or ok button
}
//At this point the splashscreen must continue freezed
if(result)
{
var mvxBundle = new MvxBundle(new Dictionary<string, string> {{BaseViewModel.NavigationBarParameter, "false"}});
await navigation.Navigate(myMainViewModel, mvxBundle);
}
else
{
//Other things
}
}
}
我尝试使用一些nuget软件包显示确认对话框,但出现错误,因为库试图将视图附加到导航堆栈,此时导航堆栈尚未初始化
我将在这方面告知您的帮助您可以允许加载应用程序,并创建一个名为StartupPage的新页面,该页面的背景与SplashScreen相似。在该页面上,您可以显示确认弹出窗口。如果验证正确,您可以将用户导航到第一个页面,或者您可以关闭应用程序或关闭确认页面,用户将进入Splashscreen后台启动页面 我想您将无法在SplashScreen上或在应用程序启动之前显示确认对话框 您还可以使用在OnStart方法中调用本机对话框