views:

419

answers:

2

In WPF/Silverlight, can I get the calculated value of a UIElement after a transformation is applied?

(Per the comment below):

I've got a stack panel and I've applied a TranformGroup to it. There are two translate and one scale transforms in this group.

(warning, psuedo code ahead)

groupTransform.children.add(new TranslateTransform());
groupTransform.children.add(new ScaleTransform());
groupTransform.children.add(new TranslateTransform());
containerToScale.RenderTransform = groupTransform;
...
// code that sets values to all the transforms

Obviously the scale transform is the one I'm most interested in.

+1  A: 

Yes, you can check ActualWidth and ActualHeight on any FrameworkElement to figure this out. You'll need to check whether it is visible though if you have elements that hide.

If you want to know after the control has loaded use the Loaded event.

mattmanser
I've checked and the StackPanel.ActualWidth and ActualHeight don't change as I apply a transformation to them. =-/
MBonig
+1  A: 

you could simply apply the transform:

control.LayoutTransform.Transform(new Point(0,0))

Rob Fonseca-Ensor