我最近將搜索合同添加到了我的應用程序。它工作得很好!但是,只要我在應用程序中搜索時沒有運行,它只會以空白屏幕開始。我做了部分即使在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。 –
非常感謝!!!!!你的建議調試這種方式對我有效(: –