Skip to content

Commit 6d65c4c

Browse files
TokenizingTextBox Crashing Fixes
1 parent 3870c87 commit 6d65c4c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Microsoft.Toolkit.Uwp.UI.Controls/TokenizingTextBox/TokenizingTextBox.Properties.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public partial class TokenizingTextBox : Control
8484
nameof(TokenDelimiter),
8585
typeof(string),
8686
typeof(TokenizingTextBox),
87-
new PropertyMetadata(string.Empty));
87+
new PropertyMetadata(" "));
8888

8989
/// <summary>
9090
/// Identifies the <see cref="TokenSpacing"/> property.

Microsoft.Toolkit.Uwp.UI.Controls/TokenizingTextBox/TokenizingTextBox.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ private void AutoSuggestBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTex
202202

203203
string t = sender.Text.Trim();
204204

205-
if (t.Contains(TokenDelimiter))
205+
if (!string.IsNullOrEmpty(TokenDelimiter) && t.Contains(TokenDelimiter))
206206
{
207207
bool lastDelimited = t[t.Length - 1] == TokenDelimiter[0];
208208

@@ -290,7 +290,7 @@ private void TokenizingTextBoxItem_Click(object sender, RoutedEventArgs e)
290290

291291
private async Task AddToken(object data)
292292
{
293-
if (data is string str)
293+
if (data is string str && TokenItemCreating != null)
294294
{
295295
var ticea = new TokenItemCreatingEventArgs(str);
296296
await TokenItemCreating.InvokeAsync(this, ticea);
@@ -450,7 +450,7 @@ private void SelectAll()
450450
/// Returns the string representation of each token item, concatenated and delimeted.
451451
/// </summary>
452452
/// <returns>Untokenized text string</returns>
453-
public string GetUntokenizedText(string tokenDelimiter = " ,")
453+
public string GetUntokenizedText(string tokenDelimiter = ", ")
454454
{
455455
var tokenStrings = new List<string>();
456456
foreach (var child in _wrapPanel.Children)

0 commit comments

Comments
 (0)