private void ClosingDropDown(bool oldValue)
{
bool delayedClosingVisual = false;
if(DropDownPopup != null)
{
delayedClosingVisual = DropDownPopup.UsesClosingVisualState;
}
#if SILVERLIGHT
RoutedPropertyChangingEventArgs<bool> args = new RoutedPropertyChangingEventArgs<bool>(IsDropDownOpenProperty, oldValue, false, true);
#else
RoutedPropertyChangingEventArgs<bool> args = new RoutedPropertyChangingEventArgs<bool>(IsDropDownOpenProperty, oldValue, false, true, DropDownClosingEvent);
#endif
OnDropDownClosing(args);
if(_view == null || _view.Count == 0)
{
delayedClosingVisual = false;
}
if(args.Cancel)
{
_ignorePropertyChange = true;
SetValue(IsDropDownOpenProperty, oldValue);
}
else
{
// Immediately close the drop down window:
// When a popup closed visual state is present, the code path is
// slightly different and the actual call to CloseDropDown will
// be called only after the visual state's transition is done
RaiseExpandCollapseAutomationEvent(oldValue, false);
if(!delayedClosingVisual)
{
CloseDropDown(oldValue, false);
}
}
UpdateVisualState(true);
}