private static void OnMinimumPopulateDelayPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
AutoCompleteBox source = d as AutoCompleteBox;
if(source != null && source._ignorePropertyChange)
{
source._ignorePropertyChange = false;
return;
}
int newValue = (int)e.NewValue;
if(newValue < 0)
{
if(source != null)
{
source._ignorePropertyChange = true;
}
d.SetValue(e.Property, e.OldValue);
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
// ReSharper disable once NotResolvedInText
Dev2.Runtime.Configuration.Properties.Resources.AutoComplete_OnMinimumPopulateDelayPropertyChanged_InvalidValue, newValue), "value");
}
// Stop any existing timer
if(source != null && source._delayTimer != null)
{
source._delayTimer.Stop();
if(newValue == 0)
{
source._delayTimer = null;
}
}
// Create or clear a dispatcher timer instance
if(source != null && newValue > 0 && source._delayTimer == null)
{
source._delayTimer = new DispatcherTimer();
source._delayTimer.Tick += source.PopulateDropDown;
}
// Set the new tick interval
if(source != null && newValue > 0 && source._delayTimer != null)
{
source._delayTimer.Interval = TimeSpan.FromMilliseconds(newValue);
}
}
#endregion public int MinimumPopulateDelay