I have a Image control rotate problem(WPF).
I have a 500px width & 300px height photo. when I place this photo in a Image control:
<window>
<grid>
<Border BorderBrush="Green" BorderThickness="4" Margin="20" VerticalAlignment="Center" HorizontalAlignment="Center">
<Image Source="test.bmp"/>
</Border>
</grid>
</window>
It looks good, the border will auto-size itself depands on image's size: 500x300.
Now I want to rotate the image 90 degree:
<window>
<grid>
<Border BorderBrush="Green" BorderThickness="4" Margin="20" VerticalAlignment="Center" HorizontalAlignment="Center">
<Image Source="test.bmp" RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="90"/>
<TranslateTransform/>
</TransformGroup>
</Image.RenderTransform>
</Image>
</Border>
</grid>
</window>
My thinking is, the border size will also change from 500x300 to 300x500.
but actually it's not - still 500x300, and the image control also hold 500x300 place.
my problem is, how to fix this?
[UPDATE: SOLVED]
I used LayoutTransform instead of RenderTransform:
<window>
<grid>
<Border BorderBrush="Green" BorderThickness="4" Margin="20" VerticalAlignment="Center" HorizontalAlignment="Center">
<Image Source="test.bmp" >
<Image.LayoutTransform>
<RotateTransform Angle="90"/>
</Image.LayoutTransform>
</Image>
</Border>
</grid>
</window>