91

I have a horizontal listbox with a custom controlIemplate. The selected item gets a dotted frame when focused. Anyone know how to get rid of it?

1 Answer 1

177

You need to set FocusVisualStyle of each ListBoxItem to null. Steps are bellow

1) Create ItemContainerStyle for the ListBox

<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}"> 
   <Setter Property="FocusVisualStyle" Value="{x:Null}"/> ....

2) Set that style to Listbox

<ListBox ItemContainerStyle="{DynamicResource ListBoxItemStyle1}"
3
  • 5
    This answer works great, but huge heads up here: If you use this method, your controls will not display any indicator of which is focused in Windows 8! With the FocusVisualStyle disabled in Windows 7, controls like Buttons still retains a blue overall highlight, but in Windows 8 it's completely impossible to tell which control in a group is focused. Jan 29, 2013 at 23:36
  • 1
    Good to know. In this case the goal was to remove the visual style for a list item containing more controls. The child controls will still have its focus style intact.
    – Vegar
    Jun 11, 2013 at 8:56
  • 3
    You can also just add the FocusVisualStyle="{x:Null}" in most cases.
    – Adephx
    Dec 10, 2020 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.