SearchHandler.OnQueryChanged(String, String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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>();
}
}