title: WPF, sibling selection like jQuery?
body: <p>I have the following XAML code as an example in my WPF application</p>
  
  <pre><code>&lt;StackPanel Height="23" Name="MSpanel" Orientation="Horizontal" Width="138" Margin="37,13,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" &gt;
      &lt;TextBox Height="23" Name="MTBox" Width="120" Text="0" /&gt;
      &lt;ScrollBar Height="23" Name="MSBar" Width="18" TouchUp="SBar_TouchUp" /&gt;
  &lt;/StackPanel&gt;
  &lt;StackPanel Height="23" Name="CSPanel" Orientation="Horizontal" Width="138" Margin="37,41,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"&gt;
      &lt;TextBox Height="23" Name="CTBox" Width="120" Text="0" /&gt;
      &lt;ScrollBar Height="23" Name="CSBar" Width="18" TouchUp="SBar_TouchUp" /&gt;
  &lt;/StackPanel&gt;
  </code></pre>
  
  <p>I have this function:</p>
  
  <pre><code>private void SBar_TouchUp(object sender, TouchEventArgs e)
  {
      //what goes here?
      //siblings.getFirst('textbox').text += 1;
  }
  </code></pre>
  
  <p>What I was hoping to do, is have 1 function that controls these "Psudo" numeric up downs in WPF. If there was some way to have a unified function that could, reference the sibling textbox, so I only have to write it once. That would be ideal.</p>
  
  <p>I'm very familiar with jQuery, and XAML looks like an HTML DOM, ... Is there a way to browse the tree?</p>
  
  <p>I realize there are existing Numeric Up Downs available to download. This idea I believe would be good to know for the future in other endeavors as well. Thanks.</p>
  
  <hr>
  
  <p>The solution that worked!</p>
  
  <pre><code>private void SBar_ValueChanged(object sender, RoutedPropertyChangedEventArgs&lt;double&gt; e)
  {
      if (e.NewValue == 0) return; //abort here, no change
  
      ScrollBar sb = (ScrollBar)sender;
      StackPanel sp = (StackPanel)sb.Parent;
      TextBox tb = (TextBox)sp.Children[0];
  
      int change = e.NewValue &lt; 0 ? 1 : -1;
      sb.Value = 0; //this will invoke this function again
      tb.Text = (Convert.ToInt32(tb.Text) + change).ToString();
  }
  </code></pre>