public void PopulateComplete()
{
// Apply the search filter
RefreshView();
// Fire the Populated event containing the read-only view data.
#if SILVERLIGHT
PopulatedEventArgs populated = new PopulatedEventArgs(new ReadOnlyCollection<object>(_view));
#else
PopulatedEventArgs populated = new PopulatedEventArgs(new ReadOnlyCollection<object>(_view), PopulatedEvent);
#endif
OnPopulated(populated);
// ReSharper disable once PossibleUnintendedReferenceComparison
if(SelectionAdapter != null && SelectionAdapter.ItemsSource != _view)
{
SelectionAdapter.ItemsSource = _view;
}
bool isDropDownOpen = _userCalledPopulate && _view.Count > 0;
if(isDropDownOpen != IsDropDownOpen)
{
_ignorePropertyChange = true;
IsDropDownOpen = isDropDownOpen;
}
if(IsDropDownOpen)
{
OpeningDropDown(false);
if(DropDownPopup != null)
{
DropDownPopup.Arrange();
}
}
else
{
ClosingDropDown(true);
}
UpdateTextCompletion(_userCalledPopulate);
}
void UpdateQueryResults(AutoCompleteBox box, Task<object[]> task, CancellationToken token) { VerifyAccess(); // // Last chance for cancellation... after this, we know we won't get canceled because cancellation can // only happen on this thread. // if (task.Status != TaskStatus.RanToCompletion || token.IsCancellationRequested) { return; } box.ItemsSource = task.Result; box.PopulateComplete(); }