WPF tab order working wrong

Error processing SSI file


  1. Piras

    • 2019/2/7

    I don't have your custom control to hand, so I created one that contained just a TextBox. After wiring this up to your XAML, I found that the tab order went as follows:

    TextBox1, TextBox2, CustomControl1, CustomControl2, TextBox3, TextBox within CustomControl1, TextBox within CustomControl2.

    Note that after TextBox2 tabbing moves the focus onto the custom controls themselves, not any child controls they happen to have. The TextBox in my custom control didn't have a TabIndex, so its TabIndex was assumed to be the default value, Int32.MaxValue (see the MSDN documentation for the TabIndex property). Hence they come last in the tab order.

    I found that things worked better if I marked the custom controls as IsTabStop="False" (I don't see why I'd want the focus on the custom controls themselves), and set the tab-index of the TextBox in the custom control to that given in the <my:CustomControl /> element by adding the attribute TabIndex="{TemplateBinding TabIndex}" to the TextBox in the custom control. Once I'd done that, the tab order was, as I would expect,

    TextBox1, TextBox2, TextBox within CustomControl1, TextBox within CustomControl2, TextBox3.

    Of course, my custom control consists only of a single TextBox, so setting a single tab-index fixed things for me. I don't have your code, so I can't say for sure, but it might be enough to set the tab-index of all child controls within your custom controls to that in the <my:CustomControl /> element in the same way.

    EDIT: if you can't use a TemplateBinding, and instead have a .xaml file with a corresponding .xaml.cs file, then you have what's called a user control, not a custom control. In that case, you can try setting the tab index inside the XAML for CustomControlA using something like the following:

    TabIndex="{Binding Path=TabIndex, RelativeSource={RelativeSource AncestorType={x:Type my:CustomControlA}}}"
  2. Santos

    • 2018/5/10

    After wiring this up to your XAML, I found that the tab order went as follows: TextBox1, TextBox2, CustomControl1, CustomControl2, TextBox3, 

  3. Devin

    • 2020/11/30

    WPF tab order working wrong. Ask Question Asked 10 years, 5 months ago. Active 10 years, 5 months ago. Viewed 11k times 4 I have a view in WPF that I have been

  4. Collins

    • 2018/8/25

    The default tab order behavior is to start with the first control of the Window and then tab through each of the child controls found within it, before moving 

  5. Kayson

    • 2017/6/15

    Please post your XAML code. In the meantime, some things to consider include:

    • Check the KeyboardNavigation.TabIndex attribute values one more time
    • Are you dynamically adding the custom tabs at runtime?
    • Are you programmatically altering or interacting with the custom controls at runtime?
    • Ensure the tabs are listed in the proper order, in the XAML markup
  6. Jaiden

    • 2021/10/5

    WPF tab order working wrong I have a view in WPF that I have been fighting to get the tab order correct on. I have three text boxes (lets call them Text1, Text2, and Text3) and two custom controls, each of which has several other text boxes and assorted controls on them (lets call them Custom1 and Custom2).

  7. Kabir

    • 2020/2/4

    In My WPF project, I have set TabIndex Property as 0,1,2,3 - For 4 Set IsTabStop to false in all the controls you don't want the 

  8. Simon

    • 2017/1/21

    I try to explain the problem in detail: when i.e. C1NUMERICBOX is inside a TAB ORDER, when the focus reaches that control, and you press TAB to continue, the next FOCUSED CONTROL is moved to the WRONG NEXT ONE (I've made many test and there isn't a specific behavior, simply your control wrong to move the next focus in the tab order).

  9. Allen

    • 2021/3/28

    I have a view in WPF that I have been fighting to get the tab order correct on. I have three text boxes (lets call them Text1, Text2, and Text3) and two 

  10. Jaylen

    • 2019/8/11

    However, sometimes the design of your Window/dialog cause WPF to use a tab order that you might not agree with, for various reasons. Also, you may decide that certain controls should not be a part of the tabbing order. Allow me to illustrate this with an example:

  11. Harry

    • 2020/8/3

    My issue is that when running my code and I attempt to tab my way through the boxes and the tabbing works backwards - as if I was pressing 

  12. Edward

    • 2020/2/17

    Getting Started with WPF Tab Navigation control, You can create the WPF application with TabNavigation control as follows: Creating project; Adding control via Designer; Adding control manually in XAML This means that when focus is changed using the tab key within the Menu, focus will move from each element and when the last element is reached focus will return to the first element. <Menu KeyboardNavigation.TabNavigation="Cycle"> <MenuItem Header="Menu Item 1" /> <MenuItem Header="Menu Item

  13. Johnathan

    • 2020/9/24

    Setting Tabindex should work in WPF as well as WinForms. You can set it in the XAML. E.g. Copy Code. <Button x:Name="Button1" TabIndex="2" 

  14. Begu

    • 2015/2/16

    Windows Presentation Foundation (WPF) custom-control-tab-order-not-working Discussion 5 7/29 behaving like a tab stop, it was just in the wrong tab order. O

  15. Ryan

    • 2021/9/7

    If there are multiple elements with a tabindex greater than 0, the tab order starts from the lowest value greater than zero and works its 

  16. Rayden

    • 2016/5/11

    Hi folks!! I have a windows form in which I have few controls , I have set the tab order for each control but its not working properly. Means when I press tab at run time it doesn't stops at desired control. even I have set the tabstop property to true.

  17. Lionel

    • 2019/10/30

    2) I am unable to tab into the textbox of the custom control in order. And in the xaml, when I try to set CustomTabIndex="3", I receive the error:.

  18. Turner

    • 2016/6/26

    You can skip elements in the tab sequence by setting KeyboardNavigation.IsTabStop on the element in XAML. KeyboardNavigation.IsTabStop="False".

  19. Tyler

    • 2020/7/6

    The objective of this technique is to provide a logical tab order in cases where the <p tabindex="0">Sed ut perspiciatis unde omnis iste natus error sit 

Comments are closed.

More Posts