title: WPF: Tab through textboxes in user controls in a Treeview
body: <p>I'm trying to implement the Tab function in my application, but it seems like nothing i try works, so i guess i just don't understand how it is intended to be used.</p>
  <p>I have a User Control (lets call it MyControl) which contains a Text Box (as well as other stuff). The MyControl is used with a Tree View. It looks like this for the user (+ signs reveals the entire user control, aswell as child MyControl if there is any, Red Arrow shows expected Tab behavior):
  <a href="https://i.stack.imgur.com/Y4YCu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Y4YCu.png" alt="Yolo" /></a></p>
  <p>In MyControl i've set IsTabStop to false for all control except TextBox, well i've pretty much set my entire application to have IsTabStop = false. I've tried setting KeyboardNavigation.TabNavigation to both &quot;Cycle&quot; and &quot;Continue&quot; on both MyControl and the TreeView, as well as the page and window that contains the TreeView. And i've tried in different combinations (cycle on treeview, continue on mycontrol and vice versa, etc).</p>
  <p>I also tried setting TabIndex to the have the same order that the MyControl objects are created. (So the top one gets 1, second one gets 2, etc).</p>
  <p>But nothing that i have tried (in all different combinations) has ever even made tab go into the TextBox that i want it to go into. So my problem is not only that the order is wrong, It just selects the &quot;treeview&quot;, making a dotted square around it. If i change some settings the focus just goes haywire to random elements, but never the textbox</p>
  <p>So, what am i doing wrong? How is Tab supposed to be implemented?</p>
  <p>Don't know what code to show, but:
  <strong>MyControl:</strong></p>
  <pre><code>&lt;UserControl x:Class=&quot;SinusManager.View.ParamNodeV&quot;
           //blaablaa
           x:Name=&quot;pn&quot;
           KeyboardNavigation.TabNavigation=&quot;Continue&quot;
           IsTabStop=&quot;True&quot;&gt;
           //blaablaa
           &lt;StackPanel Background=&quot;{StaticResource Milky} KeyboardNavigation.TabNavigation=&quot;Continue&quot;&gt;
     &lt;Grid&gt;
     //blaablaa
          &lt;TextBox x:Name=&quot;ValueBox&quot; VerticalContentAlignment=&quot;Center&quot; PreviewTextInput=&quot;NumberValidationTextBox&quot; FontFamily=&quot;{StaticResource MonoFont}&quot; Text=&quot;{Binding Path=ValueText, ElementName=pn, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;130,0,0,0&quot; VerticalAlignment=&quot;Top&quot; Height=&quot;26&quot; Width=&quot;92&quot;
                    IsTabStop=&quot;True&quot; KeyboardNavigation.TabNavigation=&quot;Continue&quot; IsReadOnly=&quot;{Binding Path=ReadOnly, ElementName=pn}&quot;&gt;
      //blaablaa
  </code></pre>
  <p><strong>TreeView UserControl</strong></p>
  <pre><code>&lt;UserControl x:Class=&quot;SinusManager.View.ParamFrameV&quot;
    //blaablaa
    x:Name=&quot;pf&quot;
    KeyboardNavigation.TabNavigation=&quot;Cycle&quot;&gt;
    &lt;Grid&gt;
      &lt;ScrollViewer VerticalScrollBarVisibility=&quot;Visible&quot; HorizontalScrollBarVisibility=&quot;Disabled&quot; Margin=&quot;0,0,0,0&quot;&gt;
          &lt;i:Interaction.Behaviors&gt;
              &lt;v:BubbleScrollEvent/&gt;
          &lt;/i:Interaction.Behaviors&gt;
            //blaablaa
           &lt;TreeView Margin=&quot;0,16,0,0&quot; KeyboardNavigation.TabNavigation=&quot;Cycle&quot; ItemsSource=&quot;{Binding Nodes}&quot; Background=&quot;{StaticResource Milky}&quot; BorderThickness=&quot;0&quot; ItemContainerStyle=&quot;{StaticResource TreeViewItemExpandedStyle}&quot; HorizontalAlignment=&quot;Left&quot; ScrollViewer.HorizontalScrollBarVisibility=&quot;Disabled&quot; ScrollViewer.VerticalScrollBarVisibility=&quot;Disabled&quot;&gt;
                  &lt;TreeView.Resources&gt;
                      &lt;HierarchicalDataTemplate DataType=&quot;{x:Type vm:ParamTextNodeVM}&quot; ItemsSource=&quot;{Binding Path=Nodes}&quot;&gt;
                          &lt;v:ParamNodeV Node=&quot;{Binding Path=NodeM}&quot; Status=&quot;{Binding Status, Mode=TwoWay}&quot; IsTabStop=&quot;True&quot; NameText=&quot;{Binding Path=Name}&quot; UnitText=&quot;{Binding Path=Unit}&quot; ValueText=&quot;{Binding Path=Value, Mode=TwoWay}&quot; RangeText=&quot;{Binding Path=Range}&quot; ValueTypeText=&quot;{Binding Path=ValueType}&quot; DescriptionText=&quot;{Binding Path=Description}&quot; ReadOnly=&quot;{Binding Path=ReadOnly}&quot; GetParameter=&quot;{Binding GetParameterCmd}&quot; SendParameter=&quot;{Binding SendParameterCmd}&quot;/&gt;
                      &lt;/HierarchicalDataTemplate&gt;
                  //blaablaa
  </code></pre>
  <p>Code above does not have the binding for TabOrder that i tried, i removed it since it did not work. But basically i had a integer that counted up for every new MyControl created and added to the TreeView and used that integer to set TabIndex on the control. No, difference in behavior with or without the TabOrder (and yes, the binding worked).</p>
  <p><strong>EDIT:</strong>
  Still no answears, i guess i will dump all code here, maybe someone will spot something, I really want to fix this.</p>
  <p>MainWindow:</p>
  <pre><code>&lt;Window x:Class=&quot;SinusManager.MainWindow&quot;
      xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
      xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
      xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;
      xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
      xmlns:local=&quot;clr-namespace:SinusManager&quot;
      xmlns:v=&quot;clr-namespace:SinusManager.View&quot;
      xmlns:vm=&quot;clr-namespace:SinusManager.ViewModel&quot;
      mc:Ignorable=&quot;d&quot;
      Loaded=&quot;Window_Loaded&quot;
      Closing=&quot;Window_Closing&quot;
      ContentRendered=&quot;Window_Shown&quot;
      Title=&quot;NFO Sinus Manager&quot; Height=&quot;450&quot; Width=&quot;800&quot; Background=&quot;{StaticResource Milky}&quot;
      Style=&quot;{StaticResource WinAll}&quot; ForceCursor=&quot;True&quot; MinHeight=&quot;375&quot; MinWidth=&quot;500&quot;
      KeyboardNavigation.TabNavigation=&quot;Cycle&quot;&gt;
  &lt;Window.DataContext&gt;
      &lt;vm:MainViewModel/&gt;
  &lt;/Window.DataContext&gt;
  &lt;Grid&gt;
      &lt;DockPanel&gt;
          &lt;Frame Source=&quot;View/Pages/StartPage.xaml&quot; x:Name=&quot;MainFrame&quot; NavigationUIVisibility=&quot;Hidden&quot;/&gt;
      &lt;/DockPanel&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>MainPage:</p>
  <pre><code>&lt;Page x:Class=&quot;SinusManager.View.MainPage&quot;
    xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
    xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
    xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot; 
    xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot; 
    xmlns:local=&quot;clr-namespace:SinusManager&quot;
    xmlns:v=&quot;clr-namespace:SinusManager.View&quot;
    xmlns:vm=&quot;clr-namespace:SinusManager.ViewModel&quot;
    mc:Ignorable=&quot;d&quot; 
    d:DesignHeight=&quot;450&quot; d:DesignWidth=&quot;800&quot;
    Title=&quot;MainPage&quot;
    KeepAlive=&quot;True&quot;
    KeyboardNavigation.TabNavigation=&quot;Cycle&quot;&gt;
  
  &lt;Grid Background=&quot;{StaticResource White}&quot; KeyboardNavigation.TabNavigation=&quot;Cycle&quot;&gt;
  
      &lt;v:IconButton x:Name=&quot;BackHomeBTN&quot; Image=&quot;{StaticResource BackHomeBTN}&quot; Margin=&quot;0&quot; VerticalAlignment=&quot;Top&quot; HorizontalAlignment=&quot;Left&quot; IconHeight=&quot;24&quot; IconWidth=&quot;36&quot; ColorPalette=&quot;{StaticResource WhiteSolid}&quot; ColorPaletteFore=&quot;{StaticResource BlackToBluePalette}&quot; Click=&quot;BackHomeBTN_Click&quot; ToolTip=&quot;{StaticResource ToolTipHome}&quot; Focusable=&quot;False&quot; IsTabStop=&quot;False&quot;&gt;
      &lt;/v:IconButton&gt;
  
      &lt;Label Margin=&quot;55,10,0,0&quot; Content=&quot;{Binding InverterInfoPanel.Name}&quot; FontFamily=&quot;{StaticResource MainFont}&quot; FontSize=&quot;16&quot; FontWeight=&quot;Bold&quot;/&gt;
  
      &lt;Grid Margin=&quot;0,0,0,0&quot; KeyboardNavigation.TabNavigation=&quot;Cycle&quot;&gt;
  
          &lt;!-- TOOL BAR--&gt;
          &lt;StackPanel Orientation=&quot;Horizontal&quot; HorizontalAlignment=&quot;Right&quot; VerticalAlignment=&quot;Top&quot; Height=&quot;50&quot; Background=&quot;{StaticResource White}&quot; Focusable=&quot;False&quot;&gt;
              &lt;v:IconButton Command=&quot;{Binding InverterInfoPanel.OpenLogCmd}&quot; Image=&quot;{StaticResource LogBTN}&quot; Content=&quot;{StaticResource TxtLog}&quot; IconMargin=&quot;0,3,0,0&quot; FontSize=&quot;11&quot; FontFamily=&quot;{StaticResource MainFont}&quot; ColorPalette=&quot;{StaticResource WhitePalette}&quot; ToolTip=&quot;{StaticResource ToolTipLog}&quot; Visibility=&quot;{Binding ComPort.IsSimulated, Converter={StaticResource InverseBooleanToVisibility}}&quot; Focusable=&quot;False&quot; IsTabStop=&quot;False&quot;/&gt;
              &lt;v:IconButton Image=&quot;{StaticResource MonitorBTN}&quot; Width=&quot;50&quot; Content=&quot;{StaticResource TxtMonitor}&quot; IconMargin=&quot;0,3,0,0&quot; FontSize=&quot;11&quot; FontFamily=&quot;{StaticResource MainFont}&quot; ColorPalette=&quot;{StaticResource WhitePalette}&quot; ToolTip=&quot;{StaticResource ToolTipMonitor}&quot; Focusable=&quot;False&quot; IsTabStop=&quot;False&quot;/&gt;
              &lt;v:IconButton Command=&quot;{Binding InverterInfoPanel.OpenModbusCmd}&quot; Image=&quot;{StaticResource HubBTN}&quot; Content=&quot;{StaticResource TxtBtnModbus}&quot; FontSize=&quot;11&quot; IconMargin=&quot;0,3,0,0&quot; FontFamily=&quot;{StaticResource MainFont}&quot; ColorPalette=&quot;{StaticResource WhitePalette}&quot; ToolTip=&quot;{StaticResource ToolTipOpenModbus}&quot; Visibility=&quot;{Binding ComPort.IsSimulated, Converter={StaticResource InverseBooleanToVisibility}}&quot; Focusable=&quot;False&quot; IsTabStop=&quot;False&quot;/&gt;
              &lt;v:IconButton Width=&quot;50&quot;  Command=&quot;{Binding InverterInfoPanel.GetAllParametersCmd}&quot; ToolTip=&quot;{StaticResource ToolTipGetAll}&quot; Image=&quot;{StaticResource ImportBTN}&quot; Content=&quot;{StaticResource TxtBtnGetFInv}&quot; FontSize=&quot;11&quot; IconMargin=&quot;0,3,0,0&quot; FontFamily=&quot;{StaticResource MainFont}&quot; ColorPalette=&quot;{StaticResource WhitePalette}&quot; Visibility=&quot;{Binding ComPort.IsSimulated, Converter={StaticResource InverseBooleanToVisibility}}&quot; Focusable=&quot;False&quot; IsTabStop=&quot;False&quot;/&gt;
              &lt;v:IconButton Width=&quot;50&quot; Command=&quot;{Binding InverterInfoPanel.SendAllParametersCmd}&quot; ToolTip=&quot;{StaticResource ToolTipSendAll}&quot; Image=&quot;{StaticResource ExportBTN}&quot; Content=&quot;{StaticResource TxtBtnSend2Inv}&quot; FontSize=&quot;11&quot; IconMargin=&quot;0,3,0,0&quot; FontFamily=&quot;{StaticResource MainFont}&quot; ColorPalette=&quot;{StaticResource WhitePalette}&quot; Visibility=&quot;{Binding ComPort.IsSimulated, Converter={StaticResource InverseBooleanToVisibility}}&quot; Focusable=&quot;False&quot; IsTabStop=&quot;False&quot;/&gt;
              &lt;v:IconButton Image=&quot;{StaticResource ResetBTN}&quot; Width=&quot;50&quot; Content=&quot;{StaticResource TxtBtnReset}&quot; ToolTip=&quot;{StaticResource ToolTipReset}&quot; IconMargin=&quot;0,3,0,0&quot; FontFamily=&quot;{StaticResource MainFont}&quot; FontSize=&quot;11&quot;  ColorPalette=&quot;{StaticResource WhitePalette}&quot; Focusable=&quot;False&quot; IsTabStop=&quot;False&quot;/&gt;
              &lt;v:IconButton Image=&quot;{StaticResource OpenBTN}&quot; Width=&quot;50&quot; Content=&quot;{StaticResource TxtOpen}&quot; ToolTip=&quot;{StaticResource ToolTipOpenFile}&quot; IconMargin=&quot;0,3,0,0&quot; FontFamily=&quot;{StaticResource MainFont}&quot; FontSize=&quot;11&quot; ColorPalette=&quot;{StaticResource WhitePalette}&quot; Focusable=&quot;False&quot; IsTabStop=&quot;False&quot;/&gt;
              &lt;v:IconButton Image=&quot;{StaticResource SaveBTN}&quot; Width=&quot;50&quot; Content=&quot;{StaticResource TxtSave}&quot; ToolTip=&quot;{StaticResource ToolTipSaveFile}&quot; IconMargin=&quot;0,3,0,0&quot; FontFamily=&quot;{StaticResource MainFont}&quot; FontSize=&quot;11&quot; ColorPalette=&quot;{StaticResource WhitePalette}&quot; Focusable=&quot;False&quot; IsTabStop=&quot;False&quot;/&gt;
              &lt;v:IconButton Command=&quot;{Binding InverterInfoPanel.CloseCmd}&quot; Image=&quot;{StaticResource CloseBTN}&quot; ToolTip=&quot;{StaticResource ToolTipClose}&quot; Width=&quot;50&quot; Content=&quot;{StaticResource TxtClose}&quot; FontSize=&quot;11&quot; IconMargin=&quot;0,3,0,0&quot; FontFamily=&quot;{StaticResource MainFont}&quot; ColorPalette=&quot;{StaticResource WhitePalette}&quot; Focusable=&quot;False&quot; IsTabStop=&quot;False&quot;/&gt;
              &lt;Grid Margin=&quot;5&quot; Width=&quot;12&quot; Height=&quot;42&quot; VerticalAlignment=&quot;Top&quot; HorizontalAlignment=&quot;Right&quot;/&gt;
              &lt;Image Source=&quot;{StaticResource NFOLogo}&quot; Margin=&quot;5&quot; Width=&quot;42&quot; Height=&quot;42&quot; VerticalAlignment=&quot;Top&quot; HorizontalAlignment=&quot;Right&quot;/&gt;
          &lt;/StackPanel&gt;
  
          &lt;DockPanel Margin=&quot;0,50,0,0&quot; Background=&quot;{StaticResource Milky}&quot; KeyboardNavigation.TabNavigation=&quot;Cycle&quot;&gt;
              &lt;v:InverterInfoPanelV x:Name=&quot;InverterPanel&quot; VerticalAlignment=&quot;Stretch&quot; HorizontalAlignment=&quot;Left&quot;/&gt;
              &lt;Grid KeyboardNavigation.TabNavigation=&quot;Cycle&quot;&gt;
                  &lt;v:ParamTabBarV VerticalAlignment=&quot;Top&quot;/&gt;
                  &lt;Frame Margin=&quot;16,32,0,0&quot; Source=&quot;ParamFrameV.xaml&quot; x:Name=&quot;pageFrame&quot; KeyboardNavigation.TabNavigation=&quot;Cycle&quot; NavigationUIVisibility=&quot;Hidden&quot; HorizontalAlignment=&quot;Stretch&quot; VerticalAlignment=&quot;Stretch&quot; BorderThickness=&quot;0&quot; Background=&quot;{StaticResource Milky}&quot;/&gt;
              &lt;/Grid&gt;
          &lt;/DockPanel&gt;
  
          &lt;Image Source=&quot;{Binding InverterInfoPanel.Image, TargetNullValue={StaticResource FileIcon}}&quot; Margin=&quot;30,35,0,0&quot; VerticalAlignment=&quot;Top&quot; HorizontalAlignment=&quot;Left&quot; Width=&quot;64&quot;/&gt;
      &lt;/Grid&gt;
  
      &lt;ItemsControl ItemsSource=&quot;{Binding Path=ComPorts}&quot; VerticalAlignment=&quot;Bottom&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;195,0,0,0&quot;&gt;
          &lt;ItemsControl.ItemsPanel&gt;
              &lt;ItemsPanelTemplate&gt;
                  &lt;StackPanel IsItemsHost=&quot;True&quot; Orientation=&quot;Horizontal&quot;/&gt;
              &lt;/ItemsPanelTemplate&gt;
          &lt;/ItemsControl.ItemsPanel&gt;
          
          &lt;ItemsControl.ItemTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;v:TextStatusButton Status=&quot;{Binding Path=Status}&quot; IsSelected=&quot;{Binding Path=IsSelected}&quot; ColorPalette=&quot;{StaticResource DarkestGrayPalette}&quot; Margin=&quot;1,0,1,0&quot;  ColorPaletteFore=&quot;{StaticResource WhiteSolid}&quot; Content=&quot;{Binding Path=Name}&quot; FontSize=&quot;11&quot; Command=&quot;{Binding Path=OpenComPortCmd}&quot; Height=&quot;24&quot; FontFamily=&quot;{StaticResource MainFont}&quot; ToolTip=&quot;{Binding Path=FullName}&quot;/&gt;
              &lt;/DataTemplate&gt;
          &lt;/ItemsControl.ItemTemplate&gt;
      &lt;/ItemsControl&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>ParamFrame:</p>
  <pre><code>&lt;UserControl x:Class=&quot;SinusManager.View.ParamFrameV&quot;
    xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
    xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
    xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot; 
    xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot; 
    mc:Ignorable=&quot;d&quot; 
    xmlns:v=&quot;clr-namespace:SinusManager.View&quot;
    xmlns:vm=&quot;clr-namespace:SinusManager.ViewModel&quot;
    xmlns:i=&quot;http://schemas.microsoft.com/xaml/behaviors&quot;
    x:Name=&quot;pf&quot;
    KeyboardNavigation.TabNavigation=&quot;Cycle&quot;&gt;
  
  &lt;UserControl.Resources&gt;
      &lt;Style TargetType=&quot;TreeViewItem&quot;&gt;
          &lt;Setter Property=&quot;IsTabStop&quot; Value=&quot;True&quot;/&gt;
          &lt;Setter Property=&quot;Focusable&quot; Value=&quot;False&quot;/&gt;
          &lt;Setter Property=&quot;KeyboardNavigation.TabNavigation&quot; Value=&quot;Continue&quot;/&gt;
      &lt;/Style&gt;
  &lt;/UserControl.Resources&gt;
  
  &lt;Grid KeyboardNavigation.TabNavigation=&quot;Cycle&quot;&gt;
      &lt;ScrollViewer VerticalScrollBarVisibility=&quot;Visible&quot; HorizontalScrollBarVisibility=&quot;Disabled&quot; Margin=&quot;0,0,0,0&quot; KeyboardNavigation.TabNavigation=&quot;Cycle&quot;&gt;
          &lt;i:Interaction.Behaviors&gt;
              &lt;v:BubbleScrollBehavior/&gt;
          &lt;/i:Interaction.Behaviors&gt;
  
          &lt;StackPanel VerticalAlignment=&quot;Top&quot; HorizontalAlignment=&quot;Left&quot; KeyboardNavigation.TabNavigation=&quot;Cycle&quot;&gt;
              &lt;Grid Width=&quot;311&quot; Height=&quot;64&quot; VerticalAlignment=&quot;Top&quot; HorizontalAlignment=&quot;Left&quot;&gt;
                  &lt;TextBlock Text=&quot;{Binding Name}&quot; FontSize=&quot;14&quot; FontFamily=&quot;{StaticResource MainFont}&quot; FontWeight=&quot;Bold&quot; Margin=&quot;6,16,0,0&quot; VerticalAlignment=&quot;Top&quot; HorizontalAlignment=&quot;Left&quot;/&gt;
                  &lt;StackPanel Orientation=&quot;Horizontal&quot; HorizontalAlignment=&quot;Right&quot; VerticalAlignment=&quot;Top&quot; Height=&quot;50&quot; Background=&quot;{StaticResource White}&quot;&gt;
                      &lt;v:IconButton IsTabStop=&quot;False&quot; Command=&quot;{Binding GetParametersCmd}&quot; Height=&quot;50&quot; Width=&quot;55&quot; Image=&quot;{StaticResource ImportBTN}&quot; Content=&quot;{StaticResource TxtGetAll}&quot; IconMargin=&quot;0,3,0,0&quot; FontFamily=&quot;{StaticResource MainFont}&quot; ColorPalette=&quot;{StaticResource MilkyPalette}&quot; ToolTip=&quot;{StaticResource ToolTipGetParas}&quot;/&gt;
                      &lt;v:IconButton IsTabStop=&quot;False&quot; Command=&quot;{Binding SendParametersCmd}&quot; Height=&quot;50&quot; Width=&quot;55&quot;  Image=&quot;{StaticResource ExportBTN}&quot; Content=&quot;{StaticResource TxtSendAll}&quot; IconMargin=&quot;0,3,0,0&quot; FontFamily=&quot;{StaticResource MainFont}&quot; ColorPalette=&quot;{StaticResource MilkyPalette}&quot; ToolTip=&quot;{StaticResource ToolTipSendParas}&quot;/&gt;
                  &lt;/StackPanel&gt;
              &lt;/Grid&gt;
  
              &lt;TreeView Margin=&quot;0,16,0,0&quot; KeyboardNavigation.TabNavigation=&quot;Cycle&quot; Focusable=&quot;False&quot; IsTabStop=&quot;False&quot; ItemsSource=&quot;{Binding Nodes}&quot; Background=&quot;{StaticResource Milky}&quot; BorderThickness=&quot;0&quot; ItemContainerStyle=&quot;{StaticResource TreeViewItemExpandedStyle}&quot; HorizontalAlignment=&quot;Left&quot; ScrollViewer.HorizontalScrollBarVisibility=&quot;Disabled&quot; ScrollViewer.VerticalScrollBarVisibility=&quot;Disabled&quot;&gt;
                  &lt;TreeView.Resources&gt;
                      &lt;HierarchicalDataTemplate DataType=&quot;{x:Type vm:ParamTextNodeVM}&quot; ItemsSource=&quot;{Binding Path=Nodes}&quot;&gt;
                          &lt;v:ParamNodeV Node=&quot;{Binding Path=NodeM}&quot; Status=&quot;{Binding Status, Mode=TwoWay}&quot; NameText=&quot;{Binding Path=Name}&quot; UnitText=&quot;{Binding Path=Unit}&quot; ValueText=&quot;{Binding Path=Value, Mode=TwoWay}&quot; RangeText=&quot;{Binding Path=Range}&quot; ValueTypeText=&quot;{Binding Path=ValueType}&quot; DescriptionText=&quot;{Binding Path=Description}&quot; ReadOnly=&quot;{Binding Path=ReadOnly}&quot; GetParameter=&quot;{Binding GetParameterCmd}&quot; SendParameter=&quot;{Binding SendParameterCmd}&quot;/&gt;
                      &lt;/HierarchicalDataTemplate&gt;
                      &lt;!--TabOrder=&quot;{Binding Path=TabOrder}&quot;--&gt;
  
                      &lt;Style TargetType=&quot;{x:Type TreeViewItem}&quot;&gt;
                          &lt;Setter Property=&quot;IsExpanded&quot; Value=&quot;{Binding Path=IsOpen}&quot;/&gt;
                      &lt;/Style&gt;
  
                      &lt;HierarchicalDataTemplate DataType=&quot;{x:Type vm:ParamGroupNodeVM}&quot; ItemsSource=&quot;{Binding Path=Nodes}&quot; &gt;
                          &lt;v:ParamGroupNodeV Node=&quot;{Binding Path=NodeM}&quot; IsTabStop=&quot;False&quot; Status=&quot;{Binding Status, Mode=TwoWay}&quot; NameText=&quot;{Binding Path=Name}&quot; ChildCount=&quot;{Binding Path=ChildCount}&quot; ReadOnly=&quot;{Binding Path=ReadOnly}&quot; IsOpen=&quot;{Binding IsExpanded, RelativeSource={RelativeSource AncestorType=TreeViewItem}, Mode=TwoWay}&quot;/&gt;
                      &lt;/HierarchicalDataTemplate&gt;
  
                      &lt;HierarchicalDataTemplate DataType=&quot;{x:Type vm:ParamComboNodeVM}&quot; ItemsSource=&quot;{Binding Path=Nodes}&quot;&gt;
                          &lt;v:ParamComboNodeV Node=&quot;{Binding Path=NodeM}&quot; IsTabStop=&quot;False&quot; Status=&quot;{Binding Status, Mode=TwoWay}&quot; NameText=&quot;{Binding Path=Name}&quot; ComboBoxItems=&quot;{Binding Path=ComboBoxItems}&quot; RangeText=&quot;{Binding Path=Range}&quot; ValueTypeText=&quot;{Binding Path=ValueType}&quot; DescriptionText=&quot;{Binding Path=Description}&quot; SelectedItem=&quot;{Binding Path=SelectedItem}&quot; ReadOnly=&quot;{Binding Path=ReadOnly}&quot;  GetParameter=&quot;{Binding GetParameterCmd}&quot; SendParameter=&quot;{Binding SendParameterCmd}&quot;/&gt;
                      &lt;/HierarchicalDataTemplate&gt;
                  &lt;/TreeView.Resources&gt;
              &lt;/TreeView&gt;
              &lt;Grid Height=&quot;50&quot;/&gt;
          &lt;/StackPanel&gt;
      &lt;/ScrollViewer&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>ParamNode:</p>
  <pre><code>&lt;UserControl x:Class=&quot;SinusManager.View.ParamNodeV&quot;
           xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
           xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
           xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot; 
           xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot; 
           xmlns:i=&quot;http://schemas.microsoft.com/xaml/behaviors&quot;
           xmlns:local=&quot;clr-namespace:SinusManager&quot;
           xmlns:v=&quot;clr-namespace:SinusManager.View&quot;
           xmlns:r=&quot;clr-namespace:SinusManager.Resources&quot;
           xmlns:vm=&quot;clr-namespace:SinusManager.ViewModel&quot;
           mc:Ignorable=&quot;d&quot; 
           x:Name=&quot;pn&quot;
           KeyboardNavigation.TabNavigation=&quot;Continue&quot; Focusable=&quot;False&quot; IsTabStop=&quot;False&quot;&gt;
  
  &lt;StackPanel Background=&quot;{StaticResource Milky}&quot;&gt;
      &lt;Grid Focusable=&quot;False&quot;&gt;
          &lt;!--&lt;v:IconButton ColorPalette=&quot;{StaticResource TransparentSolid}&quot; ColorPaletteFore=&quot;{StaticResource WhiteToBluePalette}&quot; Image=&quot;{StaticResource MiscExpanderBack}&quot; IconMargin=&quot;0&quot; Content=&quot;&quot; VerticalAlignment=&quot;Top&quot; Margin=&quot;0&quot; HorizontalAlignment=&quot;Left&quot; FontSize=&quot;1&quot; Height=&quot;26&quot; IconWidth=&quot;26&quot; IconHeight=&quot;26&quot;/&gt;--&gt;
          &lt;v:IconButton Focusable=&quot;False&quot; IsTabStop=&quot;False&quot; ColorPalette=&quot;{StaticResource WhiteToBluePalette}&quot; ImageBack=&quot;{StaticResource MiscExpanderBack}&quot; ColorPaletteFore=&quot;{StaticResource BlackSolid}&quot; IconMargin=&quot;0&quot; Content=&quot;&quot; VerticalAlignment=&quot;Top&quot; Margin=&quot;0&quot; HorizontalAlignment=&quot;Left&quot; FontSize=&quot;1&quot; Height=&quot;26&quot; IconWidth=&quot;26&quot; IconHeight=&quot;26&quot;  Click=&quot;IconButton_Click&quot;&gt;
              &lt;v:IconButton.Image&gt;
                  &lt;MultiBinding Converter=&quot;{StaticResource BivalentConverter}&quot;&gt;
                      &lt;Binding Path=&quot;IsOpen&quot; RelativeSource=&quot;{RelativeSource AncestorType=UserControl, Mode=FindAncestor}&quot;/&gt;
                      &lt;Binding Source=&quot;{StaticResource CollapseBTN}&quot;/&gt;
                      &lt;Binding Source=&quot;{StaticResource ExpandBTN}&quot;/&gt;
                  &lt;/MultiBinding&gt;
              &lt;/v:IconButton.Image&gt;
              &lt;v:IconButton.ToolTip&gt;
                  &lt;MultiBinding Converter=&quot;{StaticResource BivalentConverter}&quot;&gt;
                      &lt;Binding Path=&quot;IsOpen&quot; RelativeSource=&quot;{RelativeSource AncestorType=UserControl, Mode=FindAncestor}&quot;/&gt;
                      &lt;Binding Source=&quot;{StaticResource TxtCollapse}&quot;/&gt;
                      &lt;Binding Source=&quot;{StaticResource TxtExpand}&quot;/&gt;
                  &lt;/MultiBinding&gt;
              &lt;/v:IconButton.ToolTip&gt;
          &lt;/v:IconButton&gt;
  
          &lt;TextBox Text=&quot;{Binding Path=NameText, ElementName=pn}&quot; FontFamily=&quot;{StaticResource MainFont}&quot; VerticalContentAlignment=&quot;Center&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;26,0,0,0&quot; Height=&quot;26&quot; VerticalAlignment=&quot;Bottom&quot; IsReadOnly=&quot;True&quot; IsTabStop=&quot;False&quot; BorderThickness=&quot;0&quot; Background=&quot;{StaticResource Milky}&quot; FontWeight=&quot;Bold&quot;/&gt;
          &lt;TextBox x:Name=&quot;ValueBox&quot; VerticalContentAlignment=&quot;Center&quot; PreviewTextInput=&quot;NumberValidationTextBox&quot; FontFamily=&quot;{StaticResource MonoFont}&quot; Text=&quot;{Binding Path=ValueText, ElementName=pn, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;130,0,0,0&quot; VerticalAlignment=&quot;Top&quot; Height=&quot;26&quot; Width=&quot;92&quot;
                    Focusable=&quot;True&quot; IsTabStop=&quot;True&quot; KeyboardNavigation.TabNavigation=&quot;Continue&quot; IsReadOnly=&quot;{Binding Path=ReadOnly, ElementName=pn}&quot;&gt;
              &lt;!--TabIndex=&quot;{Binding Path=TabOrder, ElementName=pn}&quot;--&gt;
              &lt;i:Interaction.Triggers&gt;
                  &lt;i:EventTrigger EventName=&quot;LostFocus&quot;&gt;
                      &lt;i:InvokeCommandAction Command=&quot;{Binding LostFocusCmd}&quot; /&gt;
                  &lt;/i:EventTrigger&gt;
                  &lt;i:EventTrigger EventName=&quot;TextChanged&quot;&gt;
                      &lt;i:InvokeCommandAction Command=&quot;{Binding ValueChangedCmd}&quot; /&gt;
                  &lt;/i:EventTrigger&gt;
              &lt;/i:Interaction.Triggers&gt;
              &lt;TextBox.Background&gt;
                  &lt;MultiBinding Converter=&quot;{StaticResource MultiValuedConverter}&quot;&gt;
                      &lt;Binding Path=&quot;Status&quot; ElementName=&quot;pn&quot;/&gt;
                      &lt;Binding Source=&quot;{StaticResource White}&quot;/&gt;
                      &lt;Binding Source=&quot;{StaticResource White}&quot;/&gt;
                      &lt;Binding Source=&quot;{StaticResource TextBoxRed}&quot;/&gt;
                      &lt;Binding Source=&quot;{StaticResource TextBoxRed}&quot;/&gt;
                  &lt;/MultiBinding&gt;
              &lt;/TextBox.Background&gt;
          &lt;/TextBox&gt;
  
          &lt;v:ColoredImage IsTabStop=&quot;False&quot; Image=&quot;{StaticResource LockIcon}&quot; Margin=&quot;130,0,0,0&quot; Height=&quot;20&quot; Width=&quot;20&quot; Color=&quot;{StaticResource LightGrayGray}&quot; Visibility=&quot;{Binding Path=ReadOnly, ElementName=pn, Converter={StaticResource BooleanToVisibility}}&quot;/&gt;
  
          &lt;TextBox IsTabStop=&quot;False&quot; Text=&quot;{Binding Path=UnitText, ElementName=pn}&quot; FontFamily=&quot;{StaticResource MainFont}&quot; VerticalContentAlignment=&quot;Center&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;222,0,0,0&quot; VerticalAlignment=&quot;Bottom&quot; Height=&quot;26&quot; Width=&quot;73&quot; IsReadOnly=&quot;True&quot; BorderThickness=&quot;0&quot; Background=&quot;{StaticResource Milky}&quot;/&gt;
  
          &lt;!--Image=&quot;{StaticResource BoxIcon}&quot;--&gt;
          &lt;v:ColoredImage IsTabStop=&quot;False&quot; Width=&quot;20&quot; Height=&quot;20&quot; HorizontalAlignment=&quot;Right&quot; Color=&quot;{StaticResource White}&quot;&gt;
              &lt;v:ColoredImage.Image&gt;
                  &lt;MultiBinding Converter=&quot;{StaticResource MultiValuedConverter}&quot;&gt;
                      &lt;Binding Path=&quot;Status&quot; ElementName=&quot;pn&quot;/&gt;
                      &lt;Binding Source=&quot;{StaticResource CircleGUI}&quot;/&gt;
                      &lt;Binding Source=&quot;{StaticResource CircleGUI}&quot;/&gt;
                      &lt;Binding Source=&quot;{StaticResource TriangleGUI}&quot;/&gt;
                      &lt;Binding Source=&quot;{StaticResource CircleGUI}&quot;/&gt;
                  &lt;/MultiBinding&gt;
              &lt;/v:ColoredImage.Image&gt;
          &lt;/v:ColoredImage&gt;
          &lt;v:ColoredImage IsTabStop=&quot;False&quot; Width=&quot;20&quot; Height=&quot;20&quot; HorizontalAlignment=&quot;Right&quot;&gt;
              &lt;v:ColoredImage.Color&gt;
                  &lt;MultiBinding Converter=&quot;{StaticResource MultiValuedConverter}&quot;&gt;
                      &lt;Binding Path=&quot;Status&quot; ElementName=&quot;pn&quot;/&gt;
                      &lt;Binding Source=&quot;{StaticResource GreenLight}&quot;/&gt;
                      &lt;Binding Source=&quot;{StaticResource YellowLight}&quot;/&gt;
                      &lt;Binding Source=&quot;{StaticResource RedLight}&quot;/&gt;
                      &lt;Binding Source=&quot;{StaticResource BlueLight}&quot;/&gt;
                  &lt;/MultiBinding&gt;
              &lt;/v:ColoredImage.Color&gt;
              &lt;v:ColoredImage.Image&gt;
                  &lt;MultiBinding Converter=&quot;{StaticResource MultiValuedConverter}&quot;&gt;
                      &lt;Binding Path=&quot;Status&quot; ElementName=&quot;pn&quot;/&gt;
                      &lt;Binding Source=&quot;{StaticResource OkIcon}&quot;/&gt;
                      &lt;Binding Source=&quot;{StaticResource WarningIcon}&quot;/&gt;
                      &lt;Binding Source=&quot;{StaticResource ErrorIcon}&quot;/&gt;
                      &lt;Binding Source=&quot;{StaticResource UnidentifiedIcon}&quot;/&gt;
                  &lt;/MultiBinding&gt;
              &lt;/v:ColoredImage.Image&gt;
              &lt;v:ColoredImage.ToolTip&gt;
                  &lt;MultiBinding Converter=&quot;{StaticResource MultiValuedConverter}&quot;&gt;
                      &lt;Binding Path=&quot;Status&quot; ElementName=&quot;pn&quot;/&gt;
                      &lt;Binding Source=&quot;{StaticResource ToolTipOK}&quot;/&gt;
                      &lt;Binding Source=&quot;{StaticResource ToolTipNotSynced}&quot;/&gt;
                      &lt;Binding Source=&quot;{StaticResource ToolTipInvalid}&quot;/&gt;
                      &lt;Binding Source=&quot;{StaticResource ToolTipUnidentified}&quot;/&gt;
                  &lt;/MultiBinding&gt;
              &lt;/v:ColoredImage.ToolTip&gt;
          &lt;/v:ColoredImage&gt;
      &lt;/Grid&gt;
  
      &lt;Grid Margin=&quot;0,2,0,0&quot;&gt;
          &lt;Image Margin=&quot;8, -4, 0, 0&quot; Source=&quot;{StaticResource DownRight}&quot; Width=&quot;24&quot; Height=&quot;24&quot; VerticalAlignment=&quot;Top&quot; HorizontalAlignment=&quot;Left&quot; Visibility=&quot;{Binding Path=IsOpen, ElementName=pn, Converter={StaticResource BooleanToVisibility}}&quot;/&gt;
          &lt;StackPanel&gt;
              &lt;Border Width=&quot;263&quot; Name=&quot;hej&quot; HorizontalAlignment=&quot;Right&quot; VerticalAlignment=&quot;Bottom&quot; Margin=&quot;0,0,0,0&quot; BorderThickness=&quot;1&quot; BorderBrush=&quot;{StaticResource Gray}&quot; CornerRadius=&quot;5&quot; Visibility=&quot;{Binding Path=IsOpen, ElementName=pn, Converter={StaticResource BooleanToVisibility}}&quot;&gt;
                  &lt;Grid&gt;
                      &lt;WrapPanel Margin=&quot;0&quot;&gt;
                          &lt;TextBox Text=&quot;{Binding Path=DescriptionText, ElementName=pn}&quot; IsTabStop=&quot;False&quot; TextWrapping=&quot;Wrap&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;0,0,0,0&quot; VerticalAlignment=&quot;top&quot; IsReadOnly=&quot;True&quot; BorderThickness=&quot;0&quot; Width=&quot;261&quot; Background=&quot;{x:Null}&quot; /&gt;
                          &lt;TextBox Text=&quot;{StaticResource TxtValueType}&quot; IsTabStop=&quot;False&quot; HorizontalAlignment=&quot;Left&quot; VerticalAlignment=&quot;top&quot; IsReadOnly=&quot;True&quot; BorderThickness=&quot;0&quot; FontWeight=&quot;Bold&quot; FontFamily=&quot;{StaticResource MainFont}&quot; Background=&quot;{x:Null}&quot;/&gt;
                          &lt;TextBox Text=&quot;{Binding Path=ValueTypeText, ElementName=pn}&quot; IsTabStop=&quot;False&quot; HorizontalAlignment=&quot;Left&quot; VerticalAlignment=&quot;top&quot; IsReadOnly=&quot;True&quot; FontFamily=&quot;{StaticResource MainFont}&quot; BorderThickness=&quot;0&quot; Width=&quot;185&quot; Background=&quot;{x:Null}&quot;/&gt;
                          &lt;TextBox Text=&quot;{StaticResource TxtRange}&quot; IsTabStop=&quot;False&quot; HorizontalAlignment=&quot;Left&quot; VerticalAlignment=&quot;top&quot; IsReadOnly=&quot;True&quot; BorderThickness=&quot;0&quot; FontWeight=&quot;Bold&quot; FontFamily=&quot;{StaticResource MainFont}&quot; Background=&quot;{x:Null}&quot;/&gt;
                          &lt;TextBox Text=&quot;{Binding Path=RangeText, ElementName=pn}&quot; IsTabStop=&quot;False&quot; HorizontalAlignment=&quot;Left&quot; VerticalAlignment=&quot;top&quot; IsReadOnly=&quot;True&quot; FontFamily=&quot;{StaticResource MainFont}&quot; BorderThickness=&quot;0&quot; Width=&quot;210&quot; Background=&quot;{x:Null}&quot;/&gt;
                          &lt;Grid Height=&quot;62&quot; Width=&quot;250&quot;/&gt;
                      &lt;/WrapPanel&gt;
                      &lt;v:IconButton IsTabStop=&quot;False&quot; Margin=&quot;0,0,4,0&quot; Command=&quot;{Binding Path=SendParameter, ElementName=pn}&quot; HorizontalAlignment=&quot;Right&quot; VerticalAlignment=&quot;Bottom&quot; ColorPalette=&quot;{StaticResource MilkyPalette}&quot; Foreground=&quot;Black&quot; Content=&quot;{StaticResource BtnSendPara}&quot; FontSize=&quot;9&quot; FontFamily=&quot;{StaticResource MainFont}&quot; Height=&quot;62&quot; Image=&quot;{StaticResource ResourceKey=ExportBTN}&quot;/&gt;
                      &lt;v:IconButton IsTabStop=&quot;False&quot; Margin=&quot;4,0,0,0&quot; Command=&quot;{Binding Path=GetParameter, ElementName=pn}&quot; HorizontalAlignment=&quot;Left&quot; VerticalAlignment=&quot;Bottom&quot; ColorPalette=&quot;{StaticResource MilkyPalette}&quot; Foreground=&quot;Black&quot; Content=&quot;{StaticResource BtnGetPara}&quot;  FontSize=&quot;9&quot; FontFamily=&quot;{StaticResource MainFont}&quot;  Height=&quot;62&quot; Image=&quot;{StaticResource ResourceKey=ImportBTN}&quot;/&gt;
                  &lt;/Grid&gt;
              &lt;/Border&gt;
              &lt;Grid Height=&quot;3&quot;/&gt;
          &lt;/StackPanel&gt;
      &lt;/Grid&gt;
  &lt;/StackPanel&gt;
  </code></pre>
  
  <p>Control structure:
  <a href="https://i.stack.imgur.com/CsG5D.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CsG5D.png" alt="Structure" /></a></p>
  <p>The Problem:
  <a href="https://i.stack.imgur.com/e4NQs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e4NQs.png" alt="doesnt work" /></a></p>