How to prevent user control from gaining focus?

I wrote a small WPF control - a text box that displays an icon (i) that allows you to display tooltips. The relevant part of the management template is as follows:

<DockPanel>
    <local:InfoIcon DockPanel.Dock="Right" Margin="2" VerticalAlignment="Center" HelpContent="{TemplateBinding InfoTooltip}" 
                    Focusable="False" IsTabStop="False"/>
    <ScrollViewer x:Name="PART_ContentHost" Margin="2" VerticalAlignment="Center"/>
</DockPanel>

InfoIconhave IsTabStopand are Focusableexplicitly set to false. But this does not prevent this control from gaining focus when tabbing through controls:

Stolen focus

How can I prevent this part of CustomControl from getting focus?

+4
source share
1 answer

Try installing KeyboardNavigation.TabNavigation="None"in the line itself DockPanelor InfoIcon.

+2
source

Source: https://habr.com/ru/post/1541756/


All Articles