Skip to content

Commit

Permalink
Initial changes to introduce the new property and feature #4917
Browse files Browse the repository at this point in the history
  • Loading branch information
Slobodan Mumovic committed Aug 6, 2023
1 parent 2d608fd commit 1f6faa5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
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

0 comments on commit 1f6faa5

Please sign in to comment.