@@ -78,10 +78,10 @@ private void ItemsSource_PropertyChanged(DependencyObject sender, DependencyProp
78
78
{
79
79
_innerItemsSource = new InterspersedObservableCollection ( ItemsSource ) ;
80
80
81
- if ( MaxTokens . HasValue && _innerItemsSource . ItemsSource . Count > MaxTokens )
81
+ if ( ReadLocalValue ( MaxTokensProperty ) != DependencyProperty . UnsetValue && _innerItemsSource . ItemsSource . Count > MaxTokens )
82
82
{
83
83
// Reduce down to the max as necessary.
84
- for ( var i = _innerItemsSource . ItemsSource . Count - 1 ; i >= Math . Max ( MaxTokens . Value , 0 ) ; -- i )
84
+ for ( var i = _innerItemsSource . ItemsSource . Count - 1 ; i >= Math . Max ( MaxTokens , 0 ) ; -- i )
85
85
{
86
86
_innerItemsSource . Remove ( _innerItemsSource [ i ] ) ;
87
87
}
@@ -440,7 +440,7 @@ public async Task ClearAsync()
440
440
441
441
internal async Task AddTokenAsync ( object data , bool ? atEnd = null )
442
442
{
443
- if ( MaxTokens <= 0 )
443
+ if ( ReadLocalValue ( MaxTokensProperty ) != DependencyProperty . UnsetValue && MaxTokens <= 0 )
444
444
{
445
445
// No tokens for you
446
446
return ;
@@ -465,7 +465,7 @@ internal async Task AddTokenAsync(object data, bool? atEnd = null)
465
465
// If we've been typing in the last box, just add this to the end of our collection
466
466
if ( atEnd == true || _currentTextEdit == _lastTextEdit )
467
467
{
468
- if ( MaxTokens != null && _innerItemsSource . ItemsSource . Count >= MaxTokens )
468
+ if ( ReadLocalValue ( MaxTokensProperty ) != DependencyProperty . UnsetValue && _innerItemsSource . ItemsSource . Count >= MaxTokens )
469
469
{
470
470
// Remove tokens from the end until below the max number.
471
471
for ( var i = _innerItemsSource . Count - 2 ; i >= 0 ; -- i )
@@ -493,7 +493,7 @@ internal async Task AddTokenAsync(object data, bool? atEnd = null)
493
493
var edit = _currentTextEdit ;
494
494
var index = _innerItemsSource . IndexOf ( edit ) ;
495
495
496
- if ( MaxTokens != null && _innerItemsSource . ItemsSource . Count >= MaxTokens )
496
+ if ( ReadLocalValue ( MaxTokensProperty ) != DependencyProperty . UnsetValue && _innerItemsSource . ItemsSource . Count >= MaxTokens )
497
497
{
498
498
// Find the next token and remove it, until below the max number of tokens.
499
499
for ( var i = index ; i < _innerItemsSource . Count ; i ++ )
0 commit comments