Here's what I'm trying to accomplish:
- up to 5 sliders on a single y-axis "track"
- when a slider is clicked, it's draggable along the track

So I've started with a Grid control to define the "track", and Rectangle objects for the sliders. The Grid is present in XAML (name "DragBounds"), and the first Rectangle is being created like so:
Code:
Rectangle[] dragRects = new Rectangle[5];
dragRects[0] = new Rectangle();
dragRects[0].Width = 15;
dragRects[0].Height = 15;
dragRects[0].VerticalAlignment = VerticalAlignment.Top;
dragRects[0].Fill = new SolidColorBrush(Colors.White);
DragBounds.Children.Add(dragRects[0]);
Then I assigned a function to DragBounds' PreviewMouseMove, which moves the Rectangle by changing its top margin based on the mouse position:
Code:
private void DragBounds_onDrag(object sender, System.Windows.Input.MouseEventArgs e)
{
    Point mousePos = e.GetPosition(DragBounds);
    if (e.LeftButton == MouseButtonState.Pressed && mousePos.Y >= 0)
    {
        dragRects[0].Margin = new Thickness(0, mousePos.Y - dragRects[0].Height / 2, 0, 0);
    }
}
This works, but it moves the Rectangle around regardless of where I click on the Grid; I only want it to move the Rectangle if the Rectangle was clicked. So I thought to add a hittest into the function attached to DragBounds' PreviewMouseLeftButtonDown:
Code:
private void DragBounds_onClick(object sender, MouseButtonEventArgs e)
{
    startPoint = e.GetPosition(DragBounds);
    if (VisualTreeHelper.HitTest(dragRects[0], startPoint) != null)
    {
        System.Windows.Forms.MessageBox.Show("hit it", "Status", MessageBoxButtons.OK);
    }
}
For testing's sake, "hit it" should pop up when the Rectangle is clicked, and when the Rectangle has 0 margin on all sides, this works. But when the top margin is increased (and the Rectangle's position is displaced), it only pops up the message when I click at the very top of the Grid - presumably within the 15 pixel height of the original placement of the Rectangle.

What might I be doing wrong here? Moreover, if there's an entirely better way to accomplish what I want, I would like to know that as well. I am a total newb to this subject matter - so no explanation is too basic.