question

njsokalski avatar image
0 Votes"
njsokalski asked ·

IsTabStop is Ignored in ControlTemplate

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="&#xE10A;" 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.

uwp
· 1
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Sorry, I can't reproduce your problem. In the default style of TextBox, DeleteButton.IsTabStop is False, and it will not be in the focus switching list. Can you provide a minimum runnable demo so that we can reproduce your problem?

0 Votes 0 · ·

0 Answers