private async void TokenBox_TokenItemCreating(TokenizingTextBox sender, TokenItemCreatingEventArgs args) { using (args.GetDeferral()) { // Try and convert typed text to people var graph = ProviderManager.Instance.GlobalProvider.Graph; if (graph != null) { args.Item = (await graph.FindPersonAsync(args.TokenText)).CurrentPage.FirstOrDefault(); } // If we didn't find anyone, then don't add anyone. if (args.Item == null) { args.Cancel = true; // TODO: We should raise a 'person not found' type event or automatically display some feedback? } } }
private void TokenItemCreating(object sender, TokenItemCreatingEventArgs e) { // Take the user's text and convert it to our data type. e.Item = _samples.FirstOrDefault((item) => item.Text.Contains(e.TokenText, System.StringComparison.CurrentCultureIgnoreCase)); }