有没有“之前”?导航事件?
我正在使用带有导航服务的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的!尝试导航事件。当请求导航时会引发它。有关 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.
在 Silverlight 中,在导航到该页面之前会发生一个事件“OnNavigedFom”。希望对于 WPF 来说也是如此。
In Silverlight, there is an event "OnNavigatedFom" that occurs before navigating to that page.. Hope it might be the same for WPF as well..