PutraKg
PutraKg

Reputation: 2246

Why is ActualWidth/ActualHeight don't changed after performing RenderTransform?

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?

Upvotes: 1

Views: 1381

Answers (1)

TheEvilPenguin
TheEvilPenguin

Reputation: 5672

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.

Upvotes: 1

Related Questions