/// <summary> /// Remove the specified token from the list. /// </summary> /// <param name="item">Item in the list to delete</param> /// <param name="data">data </param> /// <remarks> /// the data parameter is passed in optionally to support UX UTs. When running in the UT the Container items are not manifest. /// </remarks> /// <returns><b>true</b> if the item was removed successfully, <b>false</b> otherwise</returns> private async Task <bool> RemoveTokenAsync(TokenizingTextBoxItem item, object data = null) { if (data == null) { data = ItemFromContainer(item); } if (TokenItemRemoving != null) { var tirea = new TokenItemRemovingEventArgs(data, item); await TokenItemRemoving.InvokeAsync(this, tirea); if (tirea.Cancel) { return(false); } } _innerItemsSource.Remove(data); TokenItemRemoved?.Invoke(this, data); GuardAgainstPlaceholderTextLayoutIssue(); return(true); }
private async Task RemoveToken(TokenizingTextBoxItem item) { var data = ItemFromContainer(item); if (TokenItemRemoving != null) { var tirea = new TokenItemRemovingEventArgs(data, item); await TokenItemRemoving.InvokeAsync(this, tirea); if (tirea.Cancel) { return; } } _innerItemsSource.Remove(data); TokenItemRemoved?.Invoke(this, data); }
private void RemoveToken(TokenizingTextBoxItem item) { var tirea = new TokenItemRemovedEventArgs(item?.Content, item); TokenItemRemoved?.Invoke(this, tirea); if (tirea.Cancel) { return; } SelectedItems.Remove(item.Content); var itemIndex = Math.Max(_wrapPanel.Children.IndexOf(item) - 1, 0); _wrapPanel.Children.Remove(item); if (_wrapPanel.Children[itemIndex] is Control control) { control.Focus(FocusState.Programmatic); } }