1
votes

Hi i have a wpf user control and wpf textbox control in a page, when i pressed on Tab in keyboard it's not going to next control which is a normal textbox. i had set the property Tabstop to true but nothing worked...

I have not created any special property for tab index in user control.

<StackPanel Orientation="Vertical">
  //(User Control)
  <controls:UserControl x:Name="txt_Name" Header="Name"/>  

   (Normal TextBox Control)
  <StackPanel Orientation="Vertical" Margin="10">
      <Label Content="Size" VerticalAlignment="Top" />  
      //(Normal TextBox Control)                       
      <TextBox Name="txt_sizeofFacility"/>
  </StackPanel>


  <StackPanel Orientation="Vertical" Margin="10">
     <Label Content="Age" VerticalAlignment="Top" />
     //(Normal TextBox Control)
     <TextBox Name="txt_ageofFacility"/>
  </StackPanel>

    //(User Control)
  <controls:UserControl x:Name="txt_primaryActivity"  Header="Primary Activity"/>
</StackPanel>
2
I have copied you code and I cant reproduce it... pressing tab works just fine. could you be more specific?Amit Raz
try to focus manually on txt_sizeofFacility and press Tab what's happened?safi

2 Answers

0
votes

This is my code:

<StackPanel Orientation="Vertical">
    <!--//(User Control)-->
    <controls:UserControl1 x:Name="txt_Name" />

    <!--(Normal TextBox Control)-->
    <StackPanel Orientation="Vertical" Margin="10">
        <Label Content="Size" VerticalAlignment="Top" />
        <!--//(Normal TextBox Control)-->
        <TextBox Name="txt_sizeofFacility"/>
    </StackPanel>


    <StackPanel Orientation="Vertical" Margin="10">
        <Label Content="Age" VerticalAlignment="Top" />
        <!--//(Normal TextBox Control)-->
        <TextBox Name="txt_ageofFacility"/>
    </StackPanel>

    <!--//(User Control)-->
    <controls:UserControl1 x:Name="txt_primaryActivity"  />
</StackPanel>

And this is the UserControl:

<UserControl x:Class="TabIndex.UserControl1"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         mc:Ignorable="d" 
         d:DesignHeight="300" d:DesignWidth="300">
<Grid>
        <TextBox x:Name="test"></TextBox>
</Grid>

I can reproduce. Tab works even after setting focuse manually in each textbox

0
votes

I had the same problem and found out that you can set the property below on the user control and that worked for me.

KeyboardNavigation.TabNavigation="Local"