Search code examples
c#xamlwindows-store-appsmicrosoft-metro

RenderTransformOrigin vs CenterX and CenterY


When applying a transform on a control in Windows Store apps, to set the origin of the transform, I see from the documentation that you can either set RenderTransformOrigin on the control or set CenterX and CenterY on the transform itself.

What is the difference between the two ? When both of these are set, which of them takes precedence ?


Solution

  • RenderTransformOrigin is relative, but CenterX and CenterY are absolute.

    Suppose you have an element with width and height of 100. Then if you set RenderTransformOrigin = "0.5,0.5" and CenterX = 10 and CenterY = 10 then the center is shifted 10 pixels in both vertical and horizontal directions from the origin point which is at [X = 100 * 0.5 = 50 , Y = 100 * 0.5 = 50].