Note that there are some explanatory texts on larger screens.

plurals
  1. PODrawing a focus rectangle only when control receives focus via keyboard
    primarykey
    data
    text
    <p>I want to style a <code>TabItem</code>'s "<em>focus rectangle</em>". I've learned I can do this using <code>FocusVisualStyle</code>. The problem is that <a href="http://msdn.microsoft.com/en-us/library/bb613567.aspx" rel="nofollow"><code>FocusVisualStyle</code> creates a sepearate visual tree for an adorner that is drawn on top of the control</a>. I use complex semi-transparent controls and drop-shadow effects, and I need to show the rectangle <strong>under</strong> certain elements that are part of the <code>TabItem.Template</code>.</p> <p>I've found on MSDN that I can use <a href="http://msdn.microsoft.com/en-us/library/bb613567.aspx#Alternatives" rel="nofollow"><code>IsKeyboardFocused</code> combined with trigger</a> to achieve what I need. However <a href="http://social.msdn.microsoft.com/Forums/en/wpf/thread/dec15e4b-bbc5-47b7-ad44-76f039d7b53f" rel="nofollow">further research</a> have shown <a href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/aaf7ec00-8470-4086-86da-2a8c1467bb04/" rel="nofollow">this is not correct</a>, because:</p> <blockquote> <p>Keyboard focus refer to the element that is currently receiveing keyboard input. It doesn't mean the focus is set via a keyboard navigation.</p> </blockquote> <p>One of the possible workaround might be:</p> <blockquote> <p>You can listen to key_down events to check whether an navigation key is pressed. WPF controls do this internally to display the FocusVisualStyle.</p> </blockquote> <p><strong>Is there any other, easier way to achieve what I'm trying to do?</strong> I'm not really into creating code behind, listening for events and handling all of these many different navigation keys and shortcuts.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload