HeaderedContentControl - TabIndex not working...

2 posts, 0 answers
  1. Rob
    Rob avatar
    238 posts
    Member since:
    Jan 2009

    Posted 21 May 2009 Link to this post

    I have posted about this issue previously and was told that the problem existed in SL2.  I am wondering if anybody has had any luck with SL3.

    I have copied a quick sample project below where I attempt to use both the Telerik HeaderedContentControl and the SL HeaderedContentControl to create a "Label: Control" layout for my application.  Both controls exhibit the same problem.  I am unable to switch focus from one control to the next using the tab key.  Users of the application have remarked on this as a pretty big problem considering there is a fair bit of data entry type screens...  If I press the tab key twice, the focus moves to the next control.  Is there a way to force the tabto work properly?  I'm under the impression that the TabIndex property should fix this but it doesn't seem to work...

    1 <UserControl   
    2     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    3     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    4     xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" 
    5     xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" 
    6     x:Class="SilverlightApplication5.MainControl">  
    7     <UserControl.Resources> 
    8         <Style x:Key="HeaderedContentControlStyle1" TargetType="controls:HeaderedContentControl">  
    9             <Setter Property="Foreground" Value="#FF000000"/>  
    10             <Setter Property="HorizontalContentAlignment" Value="Left"/>  
    11             <Setter Property="VerticalContentAlignment" Value="Center"/>  
    12             <Setter Property="Template">  
    13                 <Setter.Value> 
    14                     <ControlTemplate TargetType="controls:HeaderedContentControl">  
    15                         <StackPanel Orientation="Horizontal" Margin="0,5,0,5">  
    16                             <ContentPresenter Cursor="{TemplateBinding Cursor}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}"/>  
    17                             <ContentPresenter Cursor="{TemplateBinding Cursor}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>  
    18                         </StackPanel> 
    19                     </ControlTemplate> 
    20                 </Setter.Value> 
    21             </Setter> 
    22         </Style> 
    23         <SolidColorBrush x:Key="FocusBrush" Color="#ffbd69"/>  
    24         <Style x:Key="HeaderedContentControlStyle2" TargetType="telerik:HeaderedContentControl">  
    25             <Setter Property="Template">  
    26                 <Setter.Value> 
    27                     <ControlTemplate TargetType="telerik:HeaderedContentControl">  
    28                         <Grid> 
    29                             <vsm:VisualStateManager.VisualStateGroups> 
    30                                 <vsm:VisualStateGroup x:Name="CommonStates">  
    31                                     <vsm:VisualState x:Name="Normal"/>  
    32                                     <vsm:VisualState x:Name="Disabled"/>  
    33                                 </vsm:VisualStateGroup> 
    34                                 <vsm:VisualStateGroup x:Name="FocusStates">  
    35                                     <vsm:VisualState x:Name="Focused" /> 
    36                                     <vsm:VisualState x:Name="Unfocused"/>  
    37                                 </vsm:VisualStateGroup> 
    38                             </vsm:VisualStateManager.VisualStateGroups> 
    39                             <StackPanel Orientation="Horizontal" Margin="0,5,0,5">  
    40                                     <ContentPresenter x:Name="HeaderElement" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}"/>  
    41                                     <ContentPresenter/> 
    42                             </StackPanel> 
    43                         </Grid> 
    44                     </ControlTemplate> 
    45                 </Setter.Value> 
    46             </Setter> 
    47         </Style> 
    48     </UserControl.Resources> 
    50     <StackPanel x:Name="LayoutRoot" Background="#FFFAFAFA">  
    51         <controls:HeaderedContentControl Style="{StaticResource HeaderedContentControlStyle1}">  
    52             <controls:HeaderedContentControl.Header> 
    53                 <TextBlock Text="Label1:" />   
    54             </controls:HeaderedContentControl.Header> 
    55             <TextBox TabIndex="1" Text="Control1" /> 
    56         </controls:HeaderedContentControl> 
    58         <controls:HeaderedContentControl Style="{StaticResource HeaderedContentControlStyle1}">  
    59             <controls:HeaderedContentControl.Header> 
    60                 <TextBlock Text="Label2:" />   
    61             </controls:HeaderedContentControl.Header> 
    62             <TextBox TabIndex="2" Text="Control2" /> 
    63         </controls:HeaderedContentControl> 
    65         <telerik:HeaderedContentControl Style="{StaticResource HeaderedContentControlStyle2}">  
    66             <telerik:HeaderedContentControl.Header> 
    67                 <TextBlock Text="Label3:" />   
    68             </telerik:HeaderedContentControl.Header> 
    69             <TextBox TabIndex="3" Text="Control3" /> 
    70         </telerik:HeaderedContentControl> 
    72         <telerik:HeaderedContentControl Style="{StaticResource HeaderedContentControlStyle2}">  
    73             <telerik:HeaderedContentControl.Header> 
    74                 <TextBlock Text="Label4:" />   
    75             </telerik:HeaderedContentControl.Header> 
    76             <TextBox TabIndex="4" Text="Control4" /> 
    77         </telerik:HeaderedContentControl> 
    79     </StackPanel> 
    80 </UserControl> 
  2. Miroslav
    Miroslav avatar
    922 posts

    Posted 25 May 2009 Link to this post

    Hi Rob,

    Sorry for the delayed reply, we were busy with the SP2 release which will be out soon.

    Unfortunately as far as I know there have been no focus/tabbing changes from SL 2 to SL 3.

    Normally this beahavior occurs when there is a control that has its IsTabStop enabled to true when it shouldn't. Some controls (like ContentControls) by defautl have this property to true and receive the Tab focus. They have no special visual state and it is hard to realize that this is happening.

    To debug this I can suggest: override the KeyDown on the root page and on some key combination Debug.WriteLine() the currently focused item (Which you can get from the FocusManager static class). Once you identify which control takes the focus when it shouldnt (the first of the two tabs), go and set its IsTabStop property to false. Setting this property affects only the given control but NOT its children.

    Please note that you will still be able to force focusing the control with control.Focus().

    Hopefully this will help you figure what is going on.

    Also if you notice any bad behavior during tabbing through a Telerik control, do tell us.


    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top