#801 – Creating a Mirror Image Using a RenderTransform
April 18, 2013 Leave a comment
You can flip an object horizontally, so that you get a mirror image, using a ScaleTransform with the ScaleX value of -1. If you use a LayoutTransform, the object will be layed out as intended after doing the transformation.
You might, however, want to do a transform to get a mirror image only after laying everything out. To do this, you use a RenderTransform. You still set the ScaleX property to -1, but you also need to set the RenderTransformOrigin to be located in the middle of the object being transformed.
<StackPanel RenderTransformOrigin="0.5,0.5"> <StackPanel.RenderTransform> <ScaleTransform ScaleX="-1"/> </StackPanel.RenderTransform> <Label Content="Earthquake hits San Francisco!" Margin="5" FontSize="16" FontFamily="Constantia" /> <StackPanel Orientation="Horizontal" HorizontalAlignment="Center"> <DatePicker SelectedDate="4/18/1906"/> <Label Content="Horrible!" FontWeight="Bold"/> </StackPanel> <Button Content="Donate $$ Now" HorizontalAlignment="Center" Padding="10,5" Margin="15"/> </StackPanel>