我用行为(以及@XamlZealot 提供的逻辑)解决了您的问题:
internal class ComboBoxIsNotScrollingItemsBehavior : Behavior<ComboBox>
{
protected override void OnAttached()
{
this.AssociatedObject.PreviewMouseWheel += this.ComboBox_PreviewMouseWheel;
}
protected override void OnDetaching()
{
this.AssociatedObject.PreviewMouseWheel -= this.ComboBox_PreviewMouseWheel;
}
private void ComboBox_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
if (this.AssociatedObject.IsDropDownOpen == false)
{
e.Handled = true;
((FrameworkElement)this.AssociatedObject.Parent).RaiseEvent(new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta)
{
RoutedEvent = UIElement.MouseWheelEvent,
Source = sender
});
}
}
}