Ghost Developer Ghost Developer - 17 days ago 7
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}"/>
<!--TargetName="placeholder"-->
</Trigger>


enter image description here

ASh ASh
Answer

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