title: How to find the thumb of a slider to set its width
body: <p>I am creating a &quot;range slider&quot; from three slider controls stacked on top of each other. The basic idea is from here which uses two sliders.</p>
  <p><a href="http://www.thejoyofcode.com/Creating_a_Range_Slider_in_WPF_and_other_cool_tips_and_tricks_for_UserControls_.aspx" rel="nofollow noreferrer">http://www.thejoyofcode.com/Creating_a_Range_Slider_in_WPF_and_other_cool_tips_and_tricks_for_UserControls_.aspx</a></p>
  <p>I'm adding a third slider whose thumb will fill the space between the the thumbs from the other slider. The user will be able to drag this center thumb to move the two ends and maintain constant spacing between the two ends.</p>
  <p>The XAML is simply three sliders. The secret to getting it to layer nicely is in using a control template (not reprodiced here. You can find it at the above URL).</p>
  <pre><code>&lt;Grid VerticalAlignment=&quot;Top&quot;&gt;
      &lt;Border BorderThickness=&quot;0,1,0,0&quot; BorderBrush=&quot;Green&quot; VerticalAlignment=&quot;Center&quot; Height=&quot;1&quot; 
              Margin=&quot;5,0,5,0&quot;/&gt;
  
      &lt;Slider x:Name=&quot;LowerSlider&quot;
              Minimum=&quot;{Binding ElementName=root, Path=Minimum}&quot;
              Maximum=&quot;{Binding ElementName=root, Path=Maximum}&quot;
              Value=&quot;{Binding ElementName=root, Path=LowerValue, Mode=TwoWay}&quot;
              Margin=&quot;0,0,0,0&quot;
              Template=&quot;{StaticResource simpleSlider}&quot;
              /&gt;
      
      &lt;Slider x:Name=&quot;MiddleSlider&quot;
              Minimum=&quot;{Binding ElementName=root, Path=Minimum}&quot;
              Maximum=&quot;{Binding ElementName=root, Path=Maximum}&quot;
              Value=&quot;{Binding ElementName=root, Path=MiddleValue, Mode=TwoWay}&quot;
              Margin=&quot;10,0,0,0&quot;
              Template=&quot;{StaticResource simpleSlider}&quot;
              &gt;
     &lt;/Slider&gt;
      
      &lt;Slider x:Name=&quot;UpperSlider&quot;
              Minimum=&quot;{Binding ElementName=root, Path=Minimum}&quot;
              Maximum=&quot;{Binding ElementName=root, Path=Maximum}&quot;
              Value=&quot;{Binding ElementName=root, Path=UpperValue, Mode=TwoWay}&quot;
              Margin=&quot;20,0,0,0&quot;
              Template=&quot;{StaticResource simpleSlider}&quot;
              /&gt;
  &lt;/Grid&gt;
  </code></pre>
  <p>As either outer thumb is dragged, I need to resize the center thumb to fill the space between the two end thumbs.</p>
  <p>In the code behind, I can catch the movement of a thumb, and I can find the middle slider control, but I can't figure out how to programatically get to the thumb of the middle slider so that I can resize it to fill the space between the two outer thumbs.</p>
  <pre><code>private void UpperSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs&lt;double&gt; e)
      {
           Slider slider= (Slider) this.FindName(&quot;MiddleSlider&quot;);
          // how to find the middleSlider thumb so I can set
          // it's width to fill the space between the outer thumbs
      }
  </code></pre>