Nishant Rana

Nishant Rana

  • NA
  • 20
  • 0

Draw a "focusVisual" (Rectangle) only when control receives focus via keyboard, not when 'via mouse'

Nov 1 2010 5:44 AM
The problem is that I have a control which has some embedded elements within, i.e. textbox, textblock etc. For this control i I want to implement my custom "FocusVisualStyle" that just encapsulate "TextBox" not entire control. To do that i've placed triggers on "IsKeyboardFocused" property to shape my "FocusVisual" (Rectangle) just around textbox.

Everything goes well except one :-( I want FocusVisual to appear only when we got a focus via keyboard (that is what "IsKeyboardFocused" suppose to do and thats how a FocusVisual should work) but I can see the FocusVisual appear even by mouse clicking on my TextBox.

There are few workarounds, like one : handle "GotKeyboardFocus" but i guess its not really a smart approach.

Is anyone has any idea why "IsKeyboardFocused" absorbing "IsMouseCaptured" event ?

Thanks and Regards


Answers (2)