Share via


SearchHandler.OnQueryChanged(String, String) Method

Definition

Developers may override this method to respond to the Query being modified.

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

Parameters

oldValue
System.String
newValue
System.String

Remarks

A common use-case is modifying the set of suggestions as the user enters data:

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>();
    }
}

Applies to