我最近将搜索合同添加到了我的应用程序。它工作得很好!但是,只要我在应用程序中搜索时没有运行,它只会以空白屏幕开始。我做了部分即使在OnSearchActivated方法中添加搜索结果。但即使我删除了我添加的代码,空白屏幕仍然存在。我创建了一个空白项目并将搜索合同添加到它。即使应用程序未运行,它仍在运行。这个问题似乎只与我的应用程序。我无法调试它,因为它是应用程序甚至没有运行时运行的东西。告诉我一个解决方案。在OnSearchActivatedWindows Store应用程序搜索合同空白屏幕
代码和OnLaunched
Protected Overrides Async Sub OnSearchActivated(args As Windows.ApplicationModel.Activation.SearchActivatedEventArgs)
Dim previousContent As UIElement = Window.Current.Content
Dim frame As Frame = TryCast(previousContent, Frame)
If frame Is Nothing Then
frame = New Frame
Common.SuspensionManager.RegisterFrame(frame, "AppFrame")
If args.PreviousExecutionState = ApplicationExecutionState.Terminated Then
Try
Await Common.SuspensionManager.RestoreAsync()
Catch ex As Common.SuspensionManagerException
End Try
End If
End If
frame.Navigate(GetType(SearchResultsPage1), args.QueryText)
Window.Current.Content = frame
Window.Current.Activate()
End Sub
Protected Overrides Async Sub OnLaunched(args As Windows.ApplicationModel.Activation.LaunchActivatedEventArgs)
AddHandler SearchPane.GetForCurrentView.SuggestionsRequested, AddressOf OnSearchPaneSuggestionsRequested
'Contains definition of arrays ExNam, ExAbbr, ExInst, etc. removed from here to shorten the code and focus on its logic
If rootFrame Is Nothing Then
rootFrame = New Frame()
Train_Thy_Brain.Common.SuspensionManager.RegisterFrame(rootFrame, "appFrame")
If args.PreviousExecutionState = ApplicationExecutionState.Terminated Then
Await Train_Thy_Brain.Common.SuspensionManager.RestoreAsync()
End If
Window.Current.Content = rootFrame
End If
If rootFrame.Content Is Nothing Then
If Not rootFrame.Navigate(GetType(Instructions), args.Arguments) Then
Throw New Exception("Failed to create initial page")
End If
End If
Window.Current.Activate()
End Sub
“同样的命名空间定义在顶部这样做,他们都没有问题都不是。
感谢您的快速回复。我猜的问题不是关于正在加载的数据。它甚至不显示搜索界面。它显示一个纯粹的黑色屏幕。我认为问题出在帧或页面未加载。我没有触及OnSearchNavigated的代码。所以,它至少应该显示搜索页面UI。 –
非常感谢!!!!!你的建议调试这种方式对我有效(: –