views:

16

answers:

0

Hi there!

I'm having trouble to translate a usercontrol in my project, i'm implementing a drag & drop application.

Here is the layout my program, the Canvas named Buttons holds the Usercontrol that will be dragged and dropped.

alt text

When I drop the object, I want to appear in another position defined me.

I've tried to use Canvas.SetLeft(), but it won't work, I think it is using the Canvas from the UserControl, instead of the Parent Canvas.

        Canvas.SetLeft(button, 100);
        Canvas.SetTop(button, 100);

I've also tried to use TranslateTransform, but it keeps acomulating translations.

 MatrixTransform oldMt = new MatrixTransform(button.oldTranform);

   TransformGroup transforms = new TransformGroup();

   transforms.Children.Add(oldMt);

   Transform translate = new TranslateTransform(100, 100);

   transforms.Children.Add(translate);
   button.RenderTransform = transforms;

   button.oldTranform = button.RenderTransform.Value;

Any help would be apreciated.