gpt4 book ai didi

windows-phone-8 - WP MVVM 导航 OnNavigatedTO

转载 作者:行者123 更新时间:2023-12-04 16:16:57 24 4
gpt4 key购买 nike

我开始在我的应用程序中实现 MVVM,但遇到了一个问题,即不知道用户何时导航到 View 。

要在 View 之间导航,我可以使用 navigationService.Navigate(...);

如何检查导航到 View 的时间?我可以使用事件 navigationService.Navigated 吗?

是否没有其他方法可以使用,例如页面本身提供的 OnNavigatedTo?

最佳答案

XAML:

xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP71"

xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
DataContext="{Binding titleSearchViewModel, Source={StaticResource Locator}}">
<i:Interaction.Triggers>
<i:EventTrigger>
<cmd:EventToCommand Command="{Binding PageLoaded, Mode=OneWay}"/>
</i:EventTrigger>
</i:Interaction.Triggers>

虚拟机:

 private RelayCommand _PageLoaded;
public RelayCommand PageLoaded
{
get
{
if (_PageLoaded == null)
{
_PageLoaded = new RelayCommand(
() => Loaded()
);
}
return _PageLoaded;
}
}

关于windows-phone-8 - WP MVVM 导航 OnNavigatedTO,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18297371/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com