tags:

views:

36

answers:

1

Ive done some tranforms for my object in the canvas, like rotating and transforming.

How can i store the new coordinates afterwards? If I try to move the object around it will only use the new Transforms.

A: 

From what I can see, this is fairly non-trivial. Generally, you'll want to let WPF handle that kind of thing for you.

That said, here's what I've been able to come up with, based on information from here. Given a text block "textBlockName":

HwndSource hwndSource = PresentationSource.FromVisual(textBlockName) as HwndSource;

Visual root = hwndSource.RootVisual;

// Translate the point from the visual to the root.

GeneralTransform transformToRoot = textBlockName.TransformToVisual(root);

Point p = new Point(0,0);

p = transformToRoot.Transform(p);

p = hwndSource.CompositionTarget.TransformToDevice.Transform(p ) ;

//Display the top left point of the text box, after transforms.
MessageBox.Show(p.ToString() );

Edit: Looking at this further, I cannot find a better solution to this. This seems to handle every situation I can think to throw at it, though.

Ben Von Handorf
Actually i manage to do it without transforms at all. I use bitmaps own Rotate etc.
Robbskinizer