RenderTransformOrigin does not work with grouped shapes
When shapes are grouped together (tree structure), setting RenderTransformOrigin on the parent has no effect.
Take for example the code below (exported from InkScape):
Changing
to
has no effect on the way the group of objects is rotated.
Adding this in code has no effect either:
Take for example the code below (exported from InkScape):
Code: Select all
<Canvas Name="blueGroup">
<Rectangle xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Canvas.Left="256.90518" Canvas.Top="775.85822" Width="241.09563" Height="138.33356" Name="blueLeft" Fill="#FF0000FF" StrokeThickness="0.5" Stroke="#FF000000" StrokeMiterLimit="4"/>
<Rectangle xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Canvas.Left="790.47748" Canvas.Top="653.33423" Width="158.09549" Height="268.76233" Name="blueRight" Fill="#FF0000FF" StrokeThickness="0.5" Stroke="#FF000000" StrokeMiterLimit="4"/>
</Canvas>
Code: Select all
<Canvas Name="blueGroup">
Code: Select all
<Canvas Name="blueGroup" RenderTransformOrigin="0.5,0.5">
Adding this in code has no effect either:
Code: Select all
square = root.FindName<UIElement>("blueGroup");
square.SetRenderTransformOrigin(new Point(0.5f, 0.5f));
Re: RenderTransformOrigin does not work with grouped shapes
The important fact here, is that RenderTransformOrigin is relative to the bounds of the control being applied to. In your example, you are setting that property in a Canvas, whose size fill the entire screen. So, (0.5,0.5) means the center of the screen.
If I change it this way (manually limiting the size of the parent canvas) I am getting the result you want:
If I change it this way (manually limiting the size of the parent canvas) I am getting the result you want:
Code: Select all
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Canvas Name="blueGroup" RenderTransformOrigin="0.5,0.5" Width="241" Height="268">
<Canvas.RenderTransform>
<RotateTransform Angle="10"/>
</Canvas.RenderTransform>
<Rectangle Width="241.09563" Height="138.33356" Name="blueLeft" Fill="#FF0000FF" StrokeThickness="0.5" Stroke="#FF000000" StrokeMiterLimit="4"/>
<Rectangle Width="158.09549" Height="268.76233" Name="blueRight" Fill="#FF0000FF" StrokeThickness="0.5" Stroke="#FF000000" StrokeMiterLimit="4"/>
</Canvas>
</Page>
Re: RenderTransformOrigin does not work with grouped shapes
Thanks, setting the width and height of the canvas solves the problem, although I have yet to find a formula which converts the InkScape rotation center coordinates to RenderTransformOrigin, With, and Height values which give the same result.
Edit:
I found that the ViewerSvg svg to xaml converer correctly converts the Inkscape rotation center to the RenderTransformOrigin format.
Edit:
I found that the ViewerSvg svg to xaml converer correctly converts the Inkscape rotation center to the RenderTransformOrigin format.
Who is online
Users browsing this forum: Ahrefs [Bot] and 4 guests