Skip to content

Commit 2d118e8

Browse files
committed
Updated GetValue to ReadLocalValue
1 parent 86cd4d6 commit 2d118e8

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

Microsoft.Toolkit.Uwp.UI.Controls.Input/TokenizingTextBox/TokenizingTextBoxItem.AutoSuggestBox.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,18 +353,15 @@ void OnTokenCountChanged(TokenizingTextBox ttb, object value = null)
353353
maxTokensCounter.Text = $"{currentTokens}/{maxTokens}";
354354
maxTokensCounter.Visibility = Visibility.Visible;
355355

356-
maxTokensCounter.Foreground = (currentTokens == maxTokens)
356+
maxTokensCounter.Foreground = (currentTokens >= maxTokens)
357357
? new SolidColorBrush(Colors.Red)
358358
: _autoSuggestBox.Foreground;
359359
}
360360

361361
ttbi.Owner.TokenItemAdded -= OnTokenCountChanged;
362362
ttbi.Owner.TokenItemRemoved -= OnTokenCountChanged;
363363

364-
// I would have like to compared to DependencyProperty.UnsetValue, but MaximumTokensProperty value is returning 0 even though we didn't set it!
365-
// This means that the token counter will not show up for a specified maximum value of 0. However, it's a pretty uncommon scenario to offer a picker
366-
// with no ability to add items. If the case does arrive where the ttb should be unusable by design, developers should disable the control instead or setting the maximum to 0.
367-
if (Content is ITokenStringContainer str && str.IsLast && ttbi?.Owner != null && (int)ttbi.Owner.GetValue(TokenizingTextBox.MaximumTokensProperty) > 0)
364+
if (Content is ITokenStringContainer str && str.IsLast && ttbi?.Owner != null && ttbi.Owner.ReadLocalValue(TokenizingTextBox.MaximumTokensProperty) != DependencyProperty.UnsetValue)
368365
{
369366
ttbi.Owner.TokenItemAdded += OnTokenCountChanged;
370367
ttbi.Owner.TokenItemRemoved += OnTokenCountChanged;

0 commit comments

Comments
 (0)