Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keyboard focus vs logical focus in WPF

Tags:

What is the difference by Keyboard focus and logical focus in WPF? and how WPF focus is different from the focus in winform ?

like image 565
Firoz Avatar asked Aug 24 '09 06:08

Firoz


People also ask

What does .focus do in C#?

The Focus method returns true if the control successfully received input focus. The control can have the input focus while not displaying any visual cues of having the focus. This behavior is primarily observed by the nonselectable controls listed below, or any controls derived from them.


1 Answers

see Focus Overview

Keyboard focus refers to the element that is currently receiving keyboard input. There can be only one element on the whole desktop that has keyboard focus. In WPF, the element that has keyboard focus will have IsKeyboardFocused set to true. The static property FocusedElement on the Keyboard class gets the element that currently has keyboard focus.

Logical focus refers to the FocusManager.FocusedElement in a focus scope. A focus scope is an element that keeps track of the FocusedElement within its scope. When keyboard focus leaves a focus scope, the focused element will lose keyboard focus but will retain logical focus. When keyboard focus returns to the focus scope, the focused element will obtain keyboard focus. This allows for keyboard focus to be changed between multiple focus scopes but ensures that the focused element in the focus scope regains keyboard focus when focus returns to the focus scope.

like image 113
Arsen Mkrtchyan Avatar answered Oct 01 '22 04:10

Arsen Mkrtchyan