none
Hiding tab selection border on items

    Question

  • Sorry about the description, I'm not sure exactly what the damn thing is called. I want to hide the 'dotted line' that appears around WPF elements when tabbing.

    On one customers machine the selection border is mysteriously (and randomly) appearing around buttons and even around some images in a Uniform Grid that I can't even select via tabbing. They are even appearing on elements that are set to hidden which is very strange, I thought the customer was mistaken until I got the screenshots.

    I have a custom skin for everything already so hopefully the selection border is available as attribute I can set to transparent?
    Monday, December 10, 2007 1:35 PM

Answers

  • It's called the FocusVisualStyle, you can simply set : FocusVisualStyle="{x:Null}" on the objects in question, this will get rid of the dotted line Smile.

    Monday, December 10, 2007 1:54 PM

All replies

  • It's called the FocusVisualStyle, you can simply set : FocusVisualStyle="{x:Null}" on the objects in question, this will get rid of the dotted line Smile.

    Monday, December 10, 2007 1:54 PM
  • Thanks Matt! That works perfectly on my machine, I'll give it to the customer and see if he can break it again
    Monday, December 10, 2007 2:22 PM
  • Hi. I'm having a similar problem.

    However, the dotted line seems to appear only on my machine.

     

    Any ideas?

    Tuesday, December 11, 2007 5:22 PM
  •  

    Hi zkeber,

     

    that was basicaly what I was seeing. In my case it would only show on a customers machine and behave on all others.

     

    Did you try the suggested fix? Because that seems to have cured the problem in my case (I have had a report back that its stopped doing it anyway!).

    Tuesday, December 11, 2007 5:53 PM
  • I am not sure if setting FocusVisualStyle to null is the perfect solution. Wouldn't the user still have to tab through the control (but without a visual indication that the control has focus)?

     

    There's a UIElement.Focusable property that should be used to specify whether you want an element to receive keyboard focus or not. The default value for the Focusable property is dependent on the particular control, but most subclasses of Control will have Focusable=true as default.

     

    So, to disable the dotted rectangle around an element (and to remove its ability to receive keyboard focus) you do something like this:

     

    <Grid Focusable="False" />

     

    Tor Langlo

    Koda Software

    Web: http://www.kodasoftware.com

    Blog: http://torlanglo.spaces.live.com

     

    Tuesday, December 11, 2007 6:16 PM