Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent element of custom control from getting focus? [duplicate]

I wrote a small WPF control - a textbox displaying small (i) icon allowing to display popup help. The relevant part of the control template looks like the following:

<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>

The InfoIcon have IsTabStop and Focusable explicitly set to false. But that doesn't prevent that control from getting focus while tabbing through controls:

Stolen focus

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

like image 804
Spook Avatar asked May 23 '14 11:05

Spook


1 Answers

Try setting KeyboardNavigation.TabNavigation="None" in the DockPanel or the InfoIcon itself.

like image 113
weston Avatar answered Oct 15 '22 11:10

weston