I use the following method to reject SIP:
/// /// Dismisses the SIP by focusing on an ancestor of the current element that isn't a /// TextBox or PasswordBox. /// public static void DismissSip() { var focused = FocusManager.GetFocusedElement() as DependencyObject; if ((null != focused) && ((focused is TextBox) || (focused is PasswordBox))) { // Find the next focusable element that isn't a TextBox or PasswordBox // and focus it to dismiss the SIP. var focusable = (Control)(from d in focused.Ancestors() where !(d is TextBox) && !(d is PasswordBox) && d is Control select d).FirstOrDefault(); if (null != focusable) { focusable.Focus(); } } }
The Ancestors method comes from LinqToVisualTree from Colin Eberhardt. The code is used in combination with the Enter Key handler, for "tabbing" for the next TextBox or PasswordBox, so they are skipped when you select, but you can enable them if that makes sense to you.
source share