locked
SearchSuggestionsRequestDeferral.Complete() - _Message The parameter is incorrect.

    Question

  • When using the SearchBox combined with an behavior and async programming, my SearchSuggestionsReqeustDeferral returns the message 'The parameter is incorrect.'.

    I have an behavior which monitors the requests for suggestions on an SearchBox and will in his turn fills the suggestions with the appropriate results. Because it is an async call I request the deferral and complete it when I am done. To be sure, the completion is done in an action executed by the Dispatcher of the CoreWindow (DispatcherService). (See code below)

    The complete solution give me no problems when I am typing one query. But when typing an bit more random and with some shortcuts (alt + a) it will return an 'The parameter is incorrect' message. This happens in about 1/4 words I enter in an more rapid paste. Special about this situations is the rapid typing and that in debugging the request.IsCancelled is true.

    Does someone have an indication what can be problem?

    Configuration:

    - Windows 8.1 Update 1

    - VS2013 Update 2 RC

    - Windows 8.1 (Universal) project

    private async void OnSuggestionsRequested(SearchBoxSuggestionsRequestedEventArgs e)
            {
                if (string.IsNullOrEmpty(e.QueryText))
                {
                    return;
                }
    
                var request = e.Request;
                var deferral = request.GetDeferral();
    
                var section = await ServiceLocator.Default.SampleService.GetSuggestions(query);
    
                await DispatcherService.Current.RunAsync(
                    CoreDispatcherPriority.Normal,
                    () =>
                    {
                        foreach (var item in section.Items)
                        {
                            var stream =
                                RandomAccessStreamReference.CreateFromUri(
                                    new Uri("URI"));
                            request.SearchSuggestionCollection.AppendResultSuggestion(
                                "Title",
                                "DetailText",
                                "Tag",
                                stream,
                                "ImageAlt");
                        }
    
                        if (!request.IsCanceled)
                        {
                            deferral.Complete();
                        }
                    });
            }


    Monday, April 14, 2014 8:36 PM

All replies

  • Do you have a sample repro that  you can share via OneDrive/ other file sharing mechanisms?

    Windows Store Developer Solutions, follow us on Twitter: @WSDevSol|| Want more solutions? See our blog

    Monday, April 14, 2014 10:40 PM
    Moderator
  • I posted an sample here. The steps to reproduce are included in the sample.

    If you need any additional information please ask so I can help you with that.

    Tuesday, April 15, 2014 6:24 PM
  • I had the same issue until I removed the ChooseSuggestionOnEnter="True" from SearchBox.
    Friday, October 31, 2014 6:23 PM