Q:

Overriding mouse over behaviour in WPF combo box

When the list is dropped down an the mouse hovers over an item in the drop-down list, the item becomes highlighted but the selected value shown in the text box does not change unless the item is clicked. I am looking for a way to modify the mouse over behavior in a control that inherits from ComboBox. I tried overriding function like OnMouseEnter & OnMouseMove etc.

A:

You can do it by overriding OnMouseMove.  The OriginalSource property of the MouseEventArgs will give you the element directly under the mouse.  You can use ContainerFromElement to get the ComboBoxItem that contains that element and then ItemContainerGenerator.ItemFromContainer to get the item to select: 
protected override void OnMouseMove(MouseEventArgs e)
{
    base.OnMouseMove(e);
    var container = ContainerFromElement((DependencyObject)e.OriginalSource);
    if (container != null)
    {
        SelectedItem = ItemContainerGenerator.ItemFromContainer(container);
    }
}

