Monday, May 12, 2008

Problem with focus scope in WPF.

WPF contains interesting static class FocusManager. This class (more precisely: its static method SetIsFocusScope) allows to set the specified DependencyObject as a focus scope (You can read more about it here).
But we have a limitation that didn't describe in MSDN (or more precisely, I not found). We can't use all controls that were inherited from ButtonBase in this focus scope, as these controls can't capture Keyboard.Focus in this focus scope. In OnLostMouseCapture method validates whether button is located in main window's focus scope. So if it isn't, control loses Keyboard.Focus (its be after Click event).
From information from my co-worker, this behaviour will be added for buttons correct works in ToolBar.
I think that a solution of MS could be more graceful for trouble of ToolBar.

No comments: