WPF Rotate an Image and align it

后端 未结 2 832
旧巷少年郎
旧巷少年郎 2020-12-12 02:58

I\'ve an Image component where I want to rotate the source :



        
相关标签:
2条回答
  • 2020-12-12 03:15

    The problem is that the Transforms were applied after the layout pass. You should use a LayoutTransform to perform the transformation before the layout is calculated:

    <Image Name="ImageTarget" HorizontalAlignment="Left" VerticalAlignment="Top" Stretch="Uniform" RenderTransformOrigin=".5,.5">
    <Image.LayoutTransform>
        <TransformGroup>
            <ScaleTransform ScaleX="{Binding Main.BindedViewMode, Converter={StaticResource ImageSizeConverter}}" />
            <ScaleTransform ScaleY="{Binding Main.BindedViewMode, Converter={StaticResource ImageSizeConverter}}" />
            <RotateTransform Angle="-90" />
        </TransformGroup>
    </Image.LayoutTransform>
    

    0 讨论(0)
  • 2020-12-12 03:15

    I suggest you to use CompositeTransform instead of RotateTransform and ScaleTransform. Then you can call Rotate and TranslateX/TranslateY inside of the CompositeTransform tag to move your object.

    In your code dimensions was changed because of ScaleX/ScaleY!

    0 讨论(0)
提交回复
热议问题