From ee32a0a854f108afaabb9bbc07b58f665ef95161 Mon Sep 17 00:00:00 2001 From: Isac <72960101+kaismic@users.noreply.github.com> Date: Sun, 6 Oct 2024 21:22:58 +1100 Subject: [PATCH] now TokenItemAdding invokes even if data is not string --- .../TokenizingTextBox/src/TokenizingTextBox.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/components/TokenizingTextBox/src/TokenizingTextBox.cs b/components/TokenizingTextBox/src/TokenizingTextBox.cs index d3972b4e..a90f2dfe 100644 --- a/components/TokenizingTextBox/src/TokenizingTextBox.cs +++ b/components/TokenizingTextBox/src/TokenizingTextBox.cs @@ -499,9 +499,17 @@ internal async Task AddTokenAsync(object data, bool? atEnd = null) return; } - if (data is string str && TokenItemAdding != null) + if (TokenItemAdding != null) { - var tiaea = new TokenItemAddingEventArgs(str); + TokenItemAddingEventArgs tiaea; + if (data is string str) + { + tiaea = new TokenItemAddingEventArgs(str); + } + else + { + tiaea = new TokenItemAddingEventArgs(null) { Item = data }; + } await TokenItemAdding.InvokeAsync(this, tiaea); if (tiaea.Cancel)