Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ private static void TextPropertyChanged(DependencyObject d, DependencyPropertyCh
}
}

/// <summary>
/// Identifies the <see cref="KeepTextAfterQuerySubmitted"/> property.
/// </summary>
public static readonly DependencyProperty KeepTextAfterQuerySubmittedProperty = DependencyProperty.Register(
nameof(KeepTextAfterQuerySubmitted),
typeof(bool),
typeof(TokenizingTextBox),
new PropertyMetadata(false));


/// <summary>
/// Identifies the <see cref="SuggestedItemsSource"/> property.
/// </summary>
Expand Down Expand Up @@ -282,6 +292,16 @@ public string Text
set => SetValue(TextProperty, value);
}

/// <summary>
/// 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).
/// </summary>
public bool KeepTextAfterQuerySubmitted
{
get => (bool)GetValue(KeepTextAfterQuerySubmittedProperty);
set => SetValue(KeepTextAfterQuerySubmittedProperty, value);
}

/// <summary>
/// Gets or sets the items source for token suggestions.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down