.net 是否有一个“问题”;“之前”;导航事件?

.net 是否有一个“问题”;“之前”;导航事件?,.net,wpf,navigation,navigationservice,.net,Wpf,Navigation,Navigationservice,我正在使用WPF和导航服务。在浏览下一页之前,我需要了解一个情况。在导航下一页之前是否有任何事件 Navigate("MyPage1.xaml") Navigate("MyPage2.xaml")'now, I need a event which shows me : FromPage("MyPage1.xaml") before navigating to "MyPage2.xaml". 代码示例 Private Sub Window_Loaded(ByVal sender As Syst

我正在使用WPF和导航服务。在浏览下一页之前,我需要了解一个情况。在导航下一页之前是否有任何事件

Navigate("MyPage1.xaml")
Navigate("MyPage2.xaml")'now, I need a event which shows me : FromPage("MyPage1.xaml") before navigating to "MyPage2.xaml".
代码示例

Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
    Application.NavigationService = Me.ContentFrame.NavigationService
End Sub

Class Application
    ' Application-level events, such as Startup, Exit, and DispatcherUnhandledException
    ' can be handled in this file.
    Public Shared NavigationService As NavigationService
End Class



Private Sub ContentFrame_Navigated(ByVal sender As Object, ByVal e As System.Windows.Navigation.NavigationEventArgs) Handles ContentFrame.Navigated
    If Application.cLang Is Nothing Then Call InitializeLanguage()
    'The following Welcome page is never visible because e.Uri is always the NEXT page
    If e.Uri IsNot Nothing AndAlso (e.Uri.ToString.Contains("Pages/PageWelcome.xaml")) Then
        Call UpdateLanguageCombobox()
    End If
End Sub



Private Sub ContentFrame_Navigating(ByVal sender As Object, ByVal e As System.Windows.Navigation.NavigatingCancelEventArgs) Handles ContentFrame.Navigating
    Dim Uri As Uri = CType(sender, Frame).Source
    If Application.cLang Is Nothing Then Call InitializeLanguage()
    'The following Welcome page is never visible because e.Uri is always the NEXT page
    If e.Uri IsNot Nothing AndAlso (e.Uri.ToString.Contains("Pages/PageWelcome.xaml")) Then
        'Call UpdateLanguageCombobox()
    End If
End Sub

对!!试试这个活动。当请求导航时,它将被引发。有关NavigationServices事件的更多信息,请参阅的“备注”部分。

在Silverlight中,导航到该页面之前会发生一个事件“OnNavigatedFom”。。希望WPF也是如此

protected override void OnNavigatedFrom(NavigationEventArgs e) {
    base.OnNavigatedFrom(e);
}

嗨,本。问题是,“导航”也只包含下一页,而不包含当前页。哦,该死,我在电话里。。。在这种情况下,我可以调用
?CType(sender,Frame).Source.ToString
。谢谢你的建议。好的,试过了。抱歉,但问题是,在任何情况下,Uri总是包含需要加载的url。我看不到当前或最后一个uri<代码>?CType(发件人,帧)。Source.ToString不起作用。请尝试将发件人强制转换到类型导航窗口,然后访问CurrentSource属性。您好。在我写之前的一篇文章和另一篇文章中,我这样做了,但它只支持“下一个”uri,而不是当前uri。问我为什么?我不知道。但它是无法使用的。框架的铸造不起作用。也许“NavigationWindow”可能是其他的东西?但我只有一个用于导航的框架控件。我使用
Frame.Source=Uri
导航,这可能是错误的?请提供一个代码示例,说明如何设置/注册事件处理程序?