IsTabStop is Ignored in ControlTemplate
Nathan Sokalski
4,111
Reputation points
I have a UWP app that contains TextBox(s) using the following Template:
<ControlTemplate TargetType="TextBox">
<Grid Background="{TemplateBinding Background}">
<Grid.ColumnDefinitions><ColumnDefinition Width="*"/><ColumnDefinition Width="Auto"/></Grid.ColumnDefinitions>
<Grid.RowDefinitions><RowDefinition Height="Auto"/></Grid.RowDefinitions>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="Disabled"/>
<VisualState x:Name="PointerOver"/>
<VisualState x:Name="Focused"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border x:Name="BorderElement" Grid.ColumnSpan="2" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" AllowFocusOnInteraction="False"/>
<ScrollViewer x:Name="ContentElement" AutomationProperties.AccessibilityView="Raw" HorizontalScrollBarVisibility="Hidden" HorizontalScrollMode="Auto" IsHorizontalRailEnabled="False" IsTabStop="False" IsVerticalRailEnabled="False" Margin="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" VerticalScrollMode="Disabled" VerticalScrollBarVisibility="Hidden" ZoomMode="Disabled"/>
<Button x:Name="DeleteButton" Grid.Column="1" Style="{StaticResource BasicButtonRectangle}" Tag="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}}" FontSize="{TemplateBinding FontSize}" Content="" Background="Transparent" FontFamily="Segoe UI Symbol" Padding="0" Foreground="{TemplateBinding Foreground}" Margin="0" VerticalAlignment="Stretch" Width="{Binding ActualHeight,RelativeSource={RelativeSource Mode=Self}}" AllowFocusOnInteraction="False" IsTabStop="False" Click="DeleteButton_Click"/>
</Grid>
</ControlTemplate>
In this ControlTemplate, notice the Button (named "DeleteButton") with the attribute IsTabStop="False". I would expect this to remove the Button from the list of controls receiving focus when pressing the Tab key. However, this is not happening, it is still included. What is the problem? Thanks.
Sign in to answer