xamarin-forms-docs/knowledge-base/autocompleteview-remove-tok...

1.4 KiB

title description type page_title slug tags ticketid res_type
Event raised when selected tokens are removed through clear button in AutoCompleteView Which event is fired when the user presses the X on the AutoCompleteView control how-to How to get item / token removed from AutoCompleteView by clicking cross autocompleteview-remove-token-event autocompleteview, autocomplete, tokens, clear, event, Xamarin, XamarinForms 1362486, 1176309 kb

Environment

Product Version 2018.3.1109.1
Product AutoCompleteView for Xamarin

Description

This article shows which event you could handle when the end user removes any of the selected in RadAutoCompleteView tokens by tapping on the clear button.

Solution

You would need to subscribe to the CollectionChanged event of the Tokens collection of the AutoCompleteView control. Here is a quick snippet which demonstrates the approach:

autoCompleteView.Tokens.CollectionChanged += TokensCollectionChanged;

and the TokensCollectionChanged event handler:

private void TokensCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
	var removedTokens = e.OldItems;        
}

Through the NotifyCollectionChangedEventArgs you could find the added/removed items from the collection.