我们的许多输入页面是通过模式加载的,当用户按下Save时,我们执行如下所示的Command
var newTemperature = new Temperature()
{
Date = DateTime.Now,
Value = this.TemperatureValue,
CaptureType = CaptureType.Manual,
IsModified = true,
};
await this.Services.DataService.SaveAsync(newTemperature);
// Save completed, now close modal.
await this.CoreMethods.PopPageModel(data, modal, animate);如果您查看呼叫GitHub,您可以看到它处理两个进程
FreshMVVM代码处理正在弹出的页面在FreshPageModel中。。除其他外,代码从出现和消失的事件中断开钩子,将BindingContext设置为空。从上面的顺序中可以看到,这意味着在从堆栈中弹出之前,BindingContext在View上被设置为null。
这方面的问题是,在0.5秒到1.5秒之间的短时间内,用户会看到一个看起来像数据都被重置的View。如果他们刚刚按了Save键,这可能会让人感到非常不安。
如果我在调用PopPageModel之前从导航堆栈反转RaisePageWasPopped和pop中的逻辑顺序,那么这个问题就没有了。
以前没人见过这个问题吗?
任何想要指出我建议的方法的错误的FreshMVVM用户?
发布于 2020-04-09 09:34:58
这个问题的解决方案是实现我们自己的PopPageModel方法,它本质上改变了顺序,以便在调用RaisePageWasPopped之前在导航堆栈上调用PopPage
当我们想要取消页面时,这就是我们所说的
public Task DismissAsync(bool modal = true, bool animate = true)
{
return this.DispatcherService.RunOnUiThreadAsync(
async () =>
{
string navServiceName = this.CurrentNavigationServiceName;
if (this.IsModalFirstChild)
{
await this.CoreMethods.PopModalNavigationService(true);
}
else
{
IFreshNavigationService rootNavigation = FreshIOC.Container.Resolve<IFreshNavigationService>(navServiceName);
await rootNavigation.PopPage(modal, animate);
if (modal)
{
this.RaisePageWasPopped();
}
}
});
}发布于 2020-02-21 09:26:11
请注意,服务正在等待,在服务完成之前保持UI,您是否尝试过删除await并立即弹出页面,或者在服务繁忙时显示加载程序?
this.InsertReports(metadata.Reports).ConfigureAwait(false);
https://stackoverflow.com/questions/60171744
复制相似问题