首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Windows应用商店应用搜索合同空白屏幕

Windows应用商店应用搜索合同空白屏幕
EN

Stack Overflow用户
提问于 2013-04-14 20:17:52
回答 2查看 491关注 0票数 2

我最近将搜索合同添加到了我的应用程序中。它工作得很好!但是,每当我在没有运行的应用程序中进行搜索时,它只会从一个空白屏幕开始。我做了添加搜索结果的部分,甚至在OnSearchActivated方法中。但是,即使我删除了添加的代码,空白屏幕仍然存在。我创建了一个空白项目,并将搜索合同添加到其中。即使在应用程序不运行的时候,它也可以在其中工作。这个问题似乎只出现在我的应用程序上。我不能调试它,因为它是在应用程序甚至不运行时运行的东西。告诉我一个解决方案。

OnSearchActivated和OnLaunched中的代码

代码语言:javascript
复制
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

此外,命名空间定义是在顶部完成的,所以它们也不是问题。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-04-14 20:49:47

有一个调试您的应用程序的解决方案:在VS2012中,在解决方案资源管理器中右键单击您的项目,然后转到调试操作选项卡,并在启动操作部分中,选中“不启动,但在启动时调试我的代码”。

现在你可以从搜索合同中启动你的应用程序,即使它还没有运行,并对其进行调试!

现在针对您的问题,我建议您在实际搜索之前检查数据是否已加载。

票数 3
EN

Stack Overflow用户

发布于 2013-04-14 22:33:52

您可能正在使用空查询字符串进行搜索激活。检查您的搜索激活处理程序,是否正在处理空白查询文本大小写?

代码语言:javascript
复制
protected override void OnSearchActivated(SearchActivatedEventArgs args)
{
    // your app initialization code here.

    Frame frame = (Frame)Window.Current.Content;
    if (!string.IsNullOrEmpty(args.QueryText))
    {
        frame.Navigate(typeof(SearchResultsPage), args.QueryText);
    }
    else
    {
        // navigate to your app home page if the query text is empty. 
        frame.Navigate(typeof(Home), null);
    }

    Window.Current.Activate();
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15998974

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档