public void Bind() { if (this.HasBinded) { this.Unbind(); } this.HasBinded = true; DependencyObject bindedELement = this.BindedElement; if (bindedELement != null) { Keyboard.AddGotKeyboardFocusHandler(bindedELement, this._keyboardFocusChanged); Keyboard.AddLostKeyboardFocusHandler(bindedELement, this._keyboardFocusChanged); if (this._hiddenElements != null && !this.BindingToRoot) { foreach (var hiddenElement in this._hiddenElements) { Keyboard.AddGotKeyboardFocusHandler(hiddenElement, this._keyboardFocusChanged); Keyboard.AddLostKeyboardFocusHandler(hiddenElement, this._keyboardFocusChanged); } } this.UpdateFocusElement(Keyboard.FocusedElement, true); } }
private void KeyBoardControl_Loaded(object sender, RoutedEventArgs e) { if (IsEnabled) { Keyboard.AddGotKeyboardFocusHandler(Parent, GotKeyBoardHandler); } }
public ViewPage() { InitializeComponent(); DataContext = this; if (!string.IsNullOrEmpty(App.Command)) { mCurrentPage = new HistoryItem(App.Command); } else { mCurrentPage = new HistoryItem(PagesDal.DEFAULT_PAGE); } Keyboard.AddGotKeyboardFocusHandler(this, gotKeyboardFocus); Keyboard.AddLostKeyboardFocusHandler(this, lostKeyboardFocus); webBrowser1.Navigating += webBrowser1_Navigating; webBrowser1.LoadCompleted += webBrowser1_LoadCompleted; var jsinterop = new JavascriptInterop(); webBrowser1.ObjectForScripting = jsinterop; jsinterop.InvokeFromJavascript += jsinterop_InvokeFromJavascript; webBrowser1.PreviewKeyDown += webBrowser1_KeyDown; mSearchWatermarkText = textBoxSearch.Text; mSearchWatermarkBrush = textBoxSearch.Foreground; mSearchWatermarkFontStyle = textBoxSearch.FontStyle; mDal = new PagesDal(); EditCommand = new RelayCommand(() => buttonEdit_Click(null, null)); InputBindings.Add(new KeyBinding(EditCommand, new KeyGesture(Key.E, ModifierKeys.Control))); BackCommand = new RelayCommand(() => buttonBack_Click(null, null)); HomeCommand = new RelayCommand(() => buttonHome_Click(null, null)); InputBindings.Add(new KeyBinding(HomeCommand, new KeyGesture(Key.Home, ModifierKeys.Alt))); FindCommand = new RelayCommand(() => textBoxSearch.Focus()); InputBindings.Add(new KeyBinding(FindCommand, new KeyGesture(Key.OemQuestion, ModifierKeys.Control))); RecentCommand = new RelayCommand(() => recentModifications()); InputBindings.Add(new KeyBinding(RecentCommand, new KeyGesture(Key.R, ModifierKeys.Control))); initWatcher(); refresh(); restorePosition(); Loaded += (sender, e) => registerHotkey(); Unloaded += (sender, e) => unregisterHotkey(); }
private void KeyBoardControl_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e) { if (Parent != null) { if (IsEnabled) { Keyboard.AddGotKeyboardFocusHandler(Parent, GotKeyBoardHandler); } else { Keyboard.RemoveGotKeyboardFocusHandler(Parent, GotKeyBoardHandler); } } }
/// <summary> /// Subscribe to touch keyboard notifications. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ParentWindowLoaded(object sender, RoutedEventArgs e) { Window w = sender as Window; if (w != null) { // Register the window for touch KB notifications TouchKeyboardEventManager.AddHandlers(w, HandleTouchKeyboardShowing, HandleTouchKeyboardHiding); // Also register for focus changes to detect situations where a shift has caused a clipped top/bottom control Keyboard.AddGotKeyboardFocusHandler(w, HandleKeyboardFocus); w.Loaded -= ParentWindowLoaded; } }
public MainWindow() { Keyboard.AddGotKeyboardFocusHandler(this, Handler); InitializeComponent(); }