Ghost Developer Ghost Developer - 1 year ago 190
C# Question

Focus element showing unexpected rectangle in wpf

I would like to get back focus on a content control when sub-menu is closed, but an unexpected rectangle is showing in first time. Once I click on any empty space or menu item, it's gone. what's the problem

<Trigger Property="IsMouseOver" Value="False" >
<Setter Property="Background" TargetName="templateRoot" Value="#FFFFFF"/>
<Setter Property="BorderBrush" TargetName="templateRoot" Value="#FFDDDDDD"/>
<Setter Property="FocusManager.FocusedElement" Value="{Binding ElementName=placeholder}"/>

enter image description here

Answer Source

control has focus and gray dotted rectangle is its FocusVisualStyle. to remove it set FocusVisualStyle="{x:Null}"

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download