有没有“之前”?导航事件?

发布于 2024-11-04 19:37:09 字数 1646 浏览 0 评论 0原文

我正在使用带有导航服务的 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

Im using WPF with Navigation Service. I need to catch a situation before the next page is navigated. Is thera any event "before" next page is navigated?

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

code sample

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鸵鸟症 2024-11-11 19:37:09

是的!尝试导航事件。当请求导航时会引发它。有关 NavigationServices 事件的详细信息,请参阅 http://msdn 的“备注”部分.microsoft.com/en-us/library/ms615518.aspx

Yes! Try the Navigating event. It is raised when a navigation is requested. More information on NavigationServices events is found in the "Remarks" section of http://msdn.microsoft.com/en-us/library/ms615518.aspx.

山田美奈子 2024-11-11 19:37:09

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

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

In Silverlight, there is an event "OnNavigatedFom" that occurs before navigating to that page.. Hope it might be the same for WPF as well..

protected override void OnNavigatedFrom(NavigationEventArgs e) {
    base.OnNavigatedFrom(e);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文