Q:

How to rotate a dynamically created ListBoxItem on a Canvas?

In my WPF MVVM application I have a ListBox with Canvas as its ItemsPanel. The ListBox's items are dynamically created by the user when he clicks a button - the ListBox.ItemsSource is a list of items of my custom type stored in my MainViewModel which is the DataContext of my MainWindow. I would like the user to be able to rotate items using a set of Thumb controls attached to every ListBoxItem. So far I've had little success attempting to find a workable solution and I'm getting quite desperate.
Here's the most important part of my ListBoxItem's Style:
<Style TargetType="ListBoxItem">
  <Setter Property="Canvas.Left" Value="{Binding X}"/>
  <Setter Property="Canvas.Top" Value="{Binding Y}"/>
  <Setter Property="Width" Value="{Binding Width}"/>
  <Setter Property="Height" Value="{Binding Height}"/>
  <Setter Property="FocusVisualStyle" Value="{StaticResource EmptyFocusVisualStyle}"/>
    <Setter Property="Template">
      <Setter.Value>
         <ControlTemplate TargetType="ListBoxItem" >
             <Grid>
                <Control Name="RotateDecorator"   
                         Width="{Binding Width}" Height="{Binding Height}"
                         Template="{StaticResource RotateDecoratorTemplate}"
                         Visibility="Visible"/>
                          <ContentPresenter x:Name="Content" />
             </Grid>
         </ControlTemplate>
      </Setter.Value>
  </Setter>

And here you can see how it looks like: http://screenshooter.net/100101493/dhokpue
The RotateDecorator is essentially merely a set of slightly customized Thumb controls (displayed as the little triangles around the selected item in the picture) which I'd like to rotate my ListBoxItem. But I've completely run out of ideas on how to do this. The only thing I know is that I need to write suitable DragDelta and DragStarted methods to serve as event handlers. Any ideas that could ease my exasperation?
EDIT: Here are the DragStarted and DragDelta methods of the RotationThumb. Could they affect the way the moving Thumb is acting?
DragStarted:
private void RotateThumb_DragStarted(object sender, DragStartedEventArgs e)
    {
        var thumb = sender as RotateThumb;
        var parent = VisualTreeHelper.GetParent(thumb);
        for (int i = 0; i < 3; i++ )
        {
            parent = VisualTreeHelper.GetParent(parent);
        }
        this.designerItem = parent as ListBoxItem;

        if (this.designerItem != null)
        {
            this.designerCanvas = VisualTreeHelper.GetParent(this.designerItem) as Canvas;

            if (this.designerCanvas != null)
            {
                this.centerPoint = this.designerItem.TranslatePoint(
                    new Point(this.designerItem.Width * this.designerItem.RenderTransformOrigin.X,
                              this.designerItem.Height * this.designerItem.RenderTransformOrigin.Y),
                              this.designerCanvas);

                Point startPoint = Mouse.GetPosition(this.designerCanvas);
                this.startVector = Point.Subtract(startPoint, this.centerPoint);

                this.rotateTransform = this.designerItem.RenderTransform as RotateTransform;
                if (this.rotateTransform == null)
                {
                    this.designerItem.RenderTransform = new RotateTransform(0);
                    this.initialAngle = 0;
                }
                else
                {
                        this.initialAngle = this.rotateTransform.Angle;
                }
            }
        }
    }

DragDelta:
private void RotateThumb_DragDelta(object sender, DragDeltaEventArgs e)
    {
        if (this.designerItem != null && this.designerCanvas != null)
        {
            Point currentPoint = Mouse.GetPosition(this.designerCanvas);
            Vector deltaVector = Point.Subtract(currentPoint, this.centerPoint);

            double angle = Vector.AngleBetween(this.startVector, deltaVector);

            RotateTransform rotateTransform = this.designerItem.RenderTransform as RotateTransform;
            rotateTransform.Angle = this.initialAngle + Math.Round(angle, 0);
            this.designerItem.InvalidateMeasure();
        }
    }

EDIT2: Problems Solved

A:

There are several ways, but here is some pseudo-code that might get you started:
// for every drag event
Point a = listboxitem center position (or wherever you want the rotation origin)
Point b = position before drag
Point c = position after drag

// calculate and normalize vectors a-b and a-c
Vector v1 = ( b - a ).Normalized();
Vector v2 = ( c - a ).Normalized();

// calculate angles for v1 and v2 (in radians)
double a1 = Math.Atan2( v1.y, v1.x );
double a2 = Math.Atan2( v2.y, v2.x );

// the amount of rotation is then the difference between a1 and a2
// NOTE: there's a catch here, Atan2 returns angles = -π ≤ θ ≤ π, so
// the values might wrap around, which you'll need to take care of too
double angleInRadians = a2 - a1;
double angleInDegrees = ( angleInRadians / Math.PI ) * 180.0;

Then add this angle to the angle of a RotateTransform you put on the ListBoxItem.

