共用方式為


VsShellUtilities.PreFocusOptionsPageComboBox Method

Definition

If the mouse is over a combobox, this method will force focus into it, but only if the calling options page doesn't already have keyboard focus.

public:
[System::Runtime::CompilerServices::Extension]
 static void PreFocusOptionsPageComboBox(System::Windows::FrameworkElement ^ optionsPage, System::Windows::Input::MouseDevice ^ mouseDevice);
public static void PreFocusOptionsPageComboBox (this System.Windows.FrameworkElement optionsPage, System.Windows.Input.MouseDevice mouseDevice);
static member PreFocusOptionsPageComboBox : System.Windows.FrameworkElement * System.Windows.Input.MouseDevice -> unit
<Extension()>
Public Sub PreFocusOptionsPageComboBox (optionsPage As FrameworkElement, mouseDevice As MouseDevice)

Parameters

optionsPage
FrameworkElement

The options page calling this helper.

mouseDevice
MouseDevice

The mouse device received from a WPF mouse event.

Remarks

This helper is designed to work around a focus issue with WPF comboboxes hosted in Win32 UI. (If the options page doesn't have keyboard focus, and the user clicks the combobox, its drop down won't open on the first click.) By placing this method call in the OnPreviewMouseLeftButtonDown of the options page, focus is moved to the combobox before the real mouse down event is triggered. When the mouse down event does trigger, since the combobox already has focus, the dropdown opens as expected.

If an options page is not WPF, or doesn't contain any comboboxes, this method should not be called. It is designed to be called in the OnPreviewMouseLeftButtonDown override. If called from some other location, it may not function as intended.

Applies to