【发布时间】:2017-11-09 10:55:45
【问题描述】:
我有一个带有 NavigationView 的 UWP 应用。我一直在参考这个文档,其中包含除了更深入地使用 AutoSuggestBox 之外的所有内容的工作示例。 https://docs.microsoft.com/en-us/windows/uwp/controls-and-patterns/navigationview
我试图在 QuerySubmitted 上更新 MainPage NavigationView 的 ContentFrame,我尝试使用 ContentFrame.Navigate 来执行此操作,但是,这最终导致 ContentFrame 完全空白。我很困惑,因为 AutoSuggestBox 没有太多相关的内容。
我当前的代码如下所示:
private async void AutoSuggestBox_QuerySubmittedAsync(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
{
searchResultsClass.searchQuery = suggestBox.Text;
Debug.WriteLine(searchResultsClass.searchQuery);
await searchResultsClass.SearchAsync();
this.ContentFrame.Navigate(typeof(SearchResults));
}
SearchResults.xaml,与我的其他工作视图相同:
<Page
x:Class="TestApp.Views.SearchResults"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TestApp.Views"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<GridViewHeaderItem Content="Search results for ''" FontSize="36"/>
</Grid>
</Page>
【问题讨论】: