1

I have the following code to resize an image control

    private void ApplyScale()
    {
        ((CompositeTransform)img.RenderTransform).ScaleX = TotalImageScale;
        ((CompositeTransform)img.RenderTransform).ScaleY = TotalImageScale;
        Debug.WriteLine("img.Width: " + img.Width.ToString() + " - img.ActualWidth: " + img.ActualWidth.ToString());
        Debug.WriteLine("img.Height: " + img.Height.ToString() + " - img.ActualHeight: " + img.ActualHeight.ToString()); 

    }

While the code works properly, I am trying to understand why the image ActualWidth and ActualHeight do not change after the scaling. They are always the same as the Width and Height values.

How do I get the new image control size? Do I have to calculate it manually via the scale change ratio?

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
PutraKg
  • 2,226
  • 3
  • 31
  • 60

1 Answers1

1

RenderTransform isn't supposed to effect layout, which it would do if it changed ActualSize. If you use LayoutTransform it should change these values, but it is a relatively simple calculation to find the new size from the old size and the scale factors.

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
TheEvilPenguin
  • 5,634
  • 1
  • 26
  • 47
  • I see. But in windows phone 8 there's no LayoutTransform is there? – PutraKg Feb 20 '13 at 07:31
  • @PutraKg Ahh sorry, I saw LayoutTransform and ActualSize and assumed WPF. I don't know anything about WP8, but the information about RenderTransform will still be correct. – TheEvilPenguin Feb 20 '13 at 09:33