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.

Monday, May 5, 2008

Inherit properties

When I investigated WPF feature, I was interesting how use inherit property (If consider that Binding is low performance feature). I used these properties as RegisterAttached only. I have write some test samples but these didn’t work to my of the confuse. Little search in MSDN founded the root of problem. It locate in end of inherit property document, after eulogy powerful this feature.

Although property value inheritance might appear to work for nonattached dependency properties, the inheritance behavior for a nonattached property through certain element boundaries in the run-time tree is undefined. Always use RegisterAttached to register properties where you specify Inherits in the metadata.

So, this is no surprise that my samples didn’t work. You can read more here.