title: Move-able Expander
body: <p>I am trying to create a user move-able expander for my WPF project. Ideally, if the user clicks the expander button, s/he should be able to expand. If one clicks and drags the text box that say "Advanced Options" I want that person to be able to move the expander around. My code doesn't work and just expands the expander. I tried associating the click on the header with something different than expanding, but that doesn't seem to work. The xaml and C# code is below. Help?</p>
  
  <pre><code>    &lt;Expander HorizontalAlignment="Left" Margin="89,372,0,0" VerticalAlignment="Top" Height="453" Width="909" IsExpanded="True" x:Name="grid_expander"&gt;
          &lt;Expander.Header&gt;
              &lt;TextBlock HorizontalAlignment="Left" Height="22" Margin="5,0,0,0" TextWrapping="Wrap" Width="154" Foreground="White" FontSize="18" MouseDown="grid_expander_MouseDown" MouseUp="grid_expander_MouseUp" MouseMove="grid_expander_MouseMove"&gt;
                  Advanced Options
              &lt;/TextBlock&gt;
          &lt;/Expander.Header&gt;
          &lt;Expander.RenderTransform&gt;
              &lt;TranslateTransform x:Name="expander_xy"/&gt;
          &lt;/Expander.RenderTransform&gt;
      &lt;/Expander&gt;
  
  
  
  
  
  
  
  
      private void grid_expander_MouseDown(object sender, MouseButtonEventArgs e)
      {
          //e.Handled = true;
          m_start = e.GetPosition(window);
          m_startOffset = new Vector(expander_xy.X, expander_xy.Y);
          grid_expander.CaptureMouse();
  
      }
  
      private void grid_expander_MouseMove(object sender, MouseEventArgs e)
      {
          if (grid_expander.IsMouseCaptured)
          {
              Vector offset = Point.Subtract(e.GetPosition(window), m_start);
              expander_xy.X = m_startOffset.X + offset.X;
              expander_xy.Y = m_startOffset.Y + offset.Y;
          }
      }
  
      private void grid_expander_MouseUp(object sender, MouseButtonEventArgs e)
      {
          grid_expander.ReleaseMouseCapture();
      }
  </code></pre>