public ToolsOptionsPageWin32Window(IEditableObject model, UserControl view, IMessageBoxService messageBox) { this.model = model; this.view = view; this.messageBox = messageBox; this.elementHost = new DialogPageElementHost(); this.elementHost.Dock = System.Windows.Forms.DockStyle.Fill; // Hooks the child hwnd source. PresentationSource.AddSourceChangedHandler(this.view, this.OnSourceChanged); this.elementHost.Child = this.view; }
public bool OnNoMoreTabStops(TraversalRequest request) { // First, determine if we are tabbing forward or backwards // outside of our content. bool forward = true; if (request != null) { switch (request.FocusNavigationDirection) { case FocusNavigationDirection.Next: case FocusNavigationDirection.Right: case FocusNavigationDirection.Down: forward = true; break; case FocusNavigationDirection.Previous: case FocusNavigationDirection.Left: case FocusNavigationDirection.Up: forward = false; break; } } // Based on the direction, tab forward or backwards in our parent dialog. IntPtr nextHandle = DialogPageElementHost.GetNextFocusElement(_source.Handle, forward); if (nextHandle != IntPtr.Zero) { // If we were able to find another control, send focus to it and inform // WPF that we moved focus outside the HwndSource. NativeMethods.SetFocus(nextHandle); return(true); } // If we couldn't find a dialog item to focus, inform WPF that it should // continue cycling inside its own tab order. return(false); }