Skip to content

Commit

Permalink
enhance TokenizingTextBox by giving access to the IsSuggestionListOpe…
Browse files Browse the repository at this point in the history
…n property of the AutoSuggestBox

CommunityToolkit#256
  • Loading branch information
minesworld committed Oct 17, 2023
1 parent aa36a45 commit b3190d7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
18 changes: 17 additions & 1 deletion components/TokenizingTextBox/src/TokenizingTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,23 @@ public partial class TokenizingTextBox : ListViewBase
internal const string PART_PointerOverState = "PointerOver";
internal const string PART_FocusedState = "Focused";
internal const string PART_UnfocusedState = "Unfocused";
internal const string PART_MaxReachedState = "MaxReachedState";
internal const string PART_MaxReachedState = "MaxReachedState";

/// <summary>
/// Access to the AutoSuggestBox IsSuggestionListOpen property
/// </summary>
///
public bool IsSuggestionListOpen
{
get => (ContainerFromItem(_lastTextEdit) is TokenizingTextBoxItem lastContainer) ? lastContainer.IsSuggestionListOpen : false;
set
{
if (ContainerFromItem(_lastTextEdit) is TokenizingTextBoxItem lastContainer)
{
lastContainer.IsSuggestionListOpen = value;
}
}
}

/// <summary>
/// Gets a value indicating whether the shift key is currently in a pressed state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,22 @@ public partial class TokenizingTextBoxItem
/// <summary>
/// Gets a value indicating whether all text in the text box is currently selected. False otherwise.
/// </summary>
private bool IsAllSelected => _autoSuggestTextBox?.SelectedText == _autoSuggestTextBox?.Text && !string.IsNullOrEmpty(_autoSuggestTextBox?.Text);
private bool IsAllSelected => _autoSuggestTextBox?.SelectedText == _autoSuggestTextBox?.Text && !string.IsNullOrEmpty(_autoSuggestTextBox?.Text);

/// <summary>
/// Give the TokenizingTextBox access to the AutoSuggestBox IsSuggestionListOpen property
/// </summary>
internal bool IsSuggestionListOpen
{
get => (_autoSuggestBox != null) ? _autoSuggestBox.IsSuggestionListOpen : false;
set
{
if (_autoSuggestBox != null)
{
_autoSuggestBox.IsSuggestionListOpen = value;
}
}
}

/// <summary>
/// Used to track if we're on the first character of the textbox while there is selected text
Expand Down

0 comments on commit b3190d7

Please sign in to comment.