将搜索词从 SearchHandler 传递到 Xamarin Forms 4 中的 ContentPage

Passing the search term from SearchHandler to ContentPage in Xamarin Forms 4

我正在尝试使用作为 Xamarin Forms 4 的一部分实现的新 SearchHandler。到目前为止,我发现填充建议非常容易,但现在我想发起一个事件,或遵循建议确认搜索时的处理方法。

public class FoodSearchHandler: SearchHandler
{
    IFoodDataStore dataStore = new FoodDataStore();

    protected override void OnQueryConfirmed()
    {
        base.OnQueryConfirmed();
        // What to do here?
    }

    protected override void OnQueryChanged(string oldValue, string newValue)
    {
        base.OnQueryChanged(oldValue, newValue);

        if(!string.IsNullOrWhiteSpace(newValue)
        {
            // Populate suggestions
            ItemsSource = dataStore.GetSuggestions(newValue);
        }
        else
        {
            ItemsSource = null;
        } 
    }
}

public partial class FoodsPage : ContentPage
{
    ObservableCollection<Food> Foods = new ObservableCollection<Food>();

    public ItemsPage()
    {
        InitializeComponent();

        // Wire up the search handler
        Shell.SetSearchHandler(this, new FoodSearchHandler());
        BindingContext = this;
    }
}

不幸的是,尽管 alpha docs 提到了搜索处理程序,但它们不包含有关如何使用它的任何详细信息,并且示例应用程序仅演示如何填充建议。

有没有人可以指导我应该如何通知我的 ContentPage 我的 SearchHandler 已确认搜索?

所以,在阅读了 Shell 文档之后,在这种情况下我想做的似乎是使用 Shell 的新 Navigation 并导航到一条路线将搜索文本作为查询传递,例如:

protected override void OnQueryConfirmed()
{
    base.OnQueryConfirmed();

    var shell = Application.Current.MainPage as Shell;
    shell.GoToAsync($"app:///fructika/search?query={Query}", true);
}

N.B。它看起来 passing data 现在不工作,或者如果它是我做错了,但我会提出一个单独的问题。