我最近开始了一个使用带有 VB.Net 的 WPF 的学习项目 - 这是我第一次无法找到我需要的答案,如果这是基本的,请道歉。
以下网页描述了如何在现代 UI 中处理导航事件,但我无法让它工作......
在主窗口中:
Public Interface Icontent
Sub OnFragmentNavigation(e As FragmentNavigationEventArgs)
Sub OnNavigatedFrom(e As NavigationEventArgs)
Sub OnNavigatedTo(e As NavigationEventArgs)
Sub OnNavigatingFrom(e As NavigatingCancelEventArgs)
End Interface
在页面中:
Public Class Page1
Implements Icontent
Public Sub OnFragmentNavigation(e As FragmentNavigationEventArgs) Implements Icontent.OnFragmentNavigation
Debug.WriteLine("Yes")
End Sub
Public Sub OnNavigatedFrom(e As NavigationEventArgs) Implements Icontent.OnNavigatedFrom
Debug.WriteLine("Yes")
End Sub
Public Sub OnNavigatedTo(e As NavigationEventArgs) Implements Icontent.OnNavigatedTo
Debug.WriteLine("Yes")
End Sub
Public Sub OnNavigatingFrom(e As NavigatingCancelEventArgs) Implements Icontent.OnNavigatingFrom
Debug.WriteLine("Yes")
End Sub
End Class
但这些事件似乎并没有发生。我尝试将接口包含到 FirstFloor.ModernUI.Windows 命名空间中,如下所示:
Namespace FirstFloor.ModernUI.Windows
Public Interface Icontent
Sub OnFragmentNavigation(e As FragmentNavigationEventArgs)
Sub OnNavigatedFrom(e As NavigationEventArgs)
Sub OnNavigatedTo(e As NavigationEventArgs)
Sub OnNavigatingFrom(e As NavigatingCancelEventArgs)
End Interface
End Namespace
但同样,这不起作用?
标准的 WPF 事件 - IE Initialized - 工作正常。
提前致谢!