如何在MVVMCross UWP应用程序中响应toast通知
我有一个用MVVPCross编写的windows UWP应用程序。当用户单击Toast Notification消息时,将调用应用程序方法OnActivated如何在MVVMCross UWP应用程序中响应toast通知,uwp,mvvmcross,Uwp,Mvvmcross,我有一个用MVVPCross编写的windows UWP应用程序。当用户单击Toast Notification消息时,将调用应用程序方法OnActivated protected override void OnActivated(IActivatedEventArgs e) { // Handle toast activation if (e is ToastNotificationActivatedEventArgs) { var toastActi
protected override void OnActivated(IActivatedEventArgs e)
{
// Handle toast activation
if (e is ToastNotificationActivatedEventArgs)
{
var toastActivationArgs = e as ToastNotificationActivatedEventArgs;
}
}
当我收到此事件时,它希望:
- 清除导航历史记录
- 通过toast事件传递的信息重新激活主页
- 然后,主页将重新加载自身,并根据传递给它的信息设置初始选择
michael我认为您唯一需要的是当前帧的实例
if (args.Kind == ActivationKind.ToastNotification)
{
try
{
if (args.PreviousExecutionState == ApplicationExecutionState.Running)
{
var fr = Window.Current.Content as Frame;
var toastActivationArgs = args as ToastNotificationActivatedEventArgs;
fr.Navigate(typeof(MainPage), toastActivationArgs);
}
}
catch { }
}
在“导航到操作”的主页中,您可以获取导航参数并执行任何您想要的操作。我认为您唯一需要的是当前帧的实例
if (args.Kind == ActivationKind.ToastNotification)
{
try
{
if (args.PreviousExecutionState == ApplicationExecutionState.Running)
{
var fr = Window.Current.Content as Frame;
var toastActivationArgs = args as ToastNotificationActivatedEventArgs;
fr.Navigate(typeof(MainPage), toastActivationArgs);
}
}
catch { }
}
在“导航到操作”的主页上,您可以获取导航参数并执行任何您想要的操作。我对
MVVMCross
没有太多经验,但快速的谷歌搜索让我加快了速度。这就是问题所在:
Frame rootFrame=Window.Current.Content作为Frame代码>应该可以帮你完成。有关更多信息,请参阅文档。在网站上快速搜索“Current”,你就会找到代码
我对
MVVMCross
没有太多经验,但快速的谷歌搜索让我加快了速度。这就是问题所在:
Frame rootFrame=Window.Current.Content作为Frame代码>应该可以帮你完成。有关更多信息,请参阅文档。在网站上快速搜索“Current”,你就会找到代码
我认为MVVMCross与此不同。我认为MVVMCross与此不同。