Partager via


SearchHandler.OnQueryChanged(String, String) Méthode

Définition

Les développeurs peuvent substituer cette méthode pour répondre à la modification de Query.

protected virtual void OnQueryChanged (string oldValue, string newValue);
abstract member OnQueryChanged : string * string -> unit
override this.OnQueryChanged : string * string -> unit

Paramètres

oldValue
System.String
newValue
System.String

Remarques

Un cas d’usage courant consiste à modifier l’ensemble de suggestions à mesure que l’utilisateur entre des données :

protected override void OnQueryChanged(string oldValue, string newValue)
{
    base.OnQueryChanged(oldValue, newValue);
    if (string.IsNullOrWhiteSpace(newValue))
    {
        ItemsSource = null;
    }
    else
    {
        ItemsSource = MonkeyData.Monkeys
            .Where(monkey => monkey.Name.ToLower().Contains(newValue.ToLower()))
            .ToList<Animal>();
    }
}

S’applique à