diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Input/TokenizingTextBox/TokenizingTextBox.Properties.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Input/TokenizingTextBox/TokenizingTextBox.Properties.cs
index 00a826cf243..fb8b1c17afe 100644
--- a/Microsoft.Toolkit.Uwp.UI.Controls.Input/TokenizingTextBox/TokenizingTextBox.Properties.cs
+++ b/Microsoft.Toolkit.Uwp.UI.Controls.Input/TokenizingTextBox/TokenizingTextBox.Properties.cs
@@ -116,6 +116,16 @@ private static void TextPropertyChanged(DependencyObject d, DependencyPropertyCh
}
}
+ ///
+ /// Identifies the property.
+ ///
+ public static readonly DependencyProperty KeepTextAfterQuerySubmittedProperty = DependencyProperty.Register(
+ nameof(KeepTextAfterQuerySubmitted),
+ typeof(bool),
+ typeof(TokenizingTextBox),
+ new PropertyMetadata(false));
+
+
///
/// Identifies the property.
///
@@ -282,6 +292,16 @@ public string Text
set => SetValue(TextProperty, value);
}
+ ///
+ /// Gets or sets a value indicating whether the control should keep or clear the text
+ /// after the query is submitted. Default is false (to clear the text).
+ ///
+ public bool KeepTextAfterQuerySubmitted
+ {
+ get => (bool)GetValue(KeepTextAfterQuerySubmittedProperty);
+ set => SetValue(KeepTextAfterQuerySubmittedProperty, value);
+ }
+
///
/// Gets or sets the items source for token suggestions.
///
diff --git a/Microsoft.Toolkit.Uwp.UI.Controls.Input/TokenizingTextBox/TokenizingTextBoxItem.AutoSuggestBox.cs b/Microsoft.Toolkit.Uwp.UI.Controls.Input/TokenizingTextBox/TokenizingTextBoxItem.AutoSuggestBox.cs
index 6b58b24bd1b..7f0fbfdb94b 100644
--- a/Microsoft.Toolkit.Uwp.UI.Controls.Input/TokenizingTextBox/TokenizingTextBoxItem.AutoSuggestBox.cs
+++ b/Microsoft.Toolkit.Uwp.UI.Controls.Input/TokenizingTextBox/TokenizingTextBoxItem.AutoSuggestBox.cs
@@ -153,8 +153,12 @@ private async void AutoSuggestBox_QuerySubmitted(AutoSuggestBox sender, AutoSugg
if (chosenItem != null)
{
await Owner.AddTokenAsync(chosenItem); // TODO: Need to pass index?
- sender.Text = string.Empty;
- Owner.Text = string.Empty;
+ if (!Owner.KeepTextAfterQuerySubmitted)
+ {
+ sender.Text = string.Empty;
+ Owner.Text = string.Empty;
+ }
+
sender.Focus(FocusState.Programmatic);
}
}