How can I resize a WPF element after rotation, and not earlier?

I have a simple, horizontal element <Line>. This line applies RotateTransform, which is tilted to any angle that I choose. The problem is that the processed string length is computed before when the conversion is applied. As a result, the line no longer matches its parent after its rotation.

My current code is similar to this using the 15 ° example:

<Grid Background="Orange">
    <Line   HorizontalAlignment="Left" VerticalAlignment="Bottom"
            RenderTransformOrigin="0,0" Stretch="UniformToFill"
            StrokeThickness="1" Stroke="Green" X1="0" Y1="0" X2="1" Y2="0">
        <UIElement.RenderTransform>
            <RotateTransform Angle="-15" />
        </UIElement.RenderTransform>
    </Line>
</Grid>

The result is the following:
http://img179.imageshack.us/img179/2592/slantpartial.png
As shown, the line does not contact the right side of the control due to rotation. I need the line to stretch to the largest size and completely fill its parent control, no matter what I set the angle for. The angle will dynamically change at runtime, and I cannot use tilt calculation in my current project. I need RotateTransform to be a line slope.

An example of what I need to do is again using the 15 ° example:
http://img42.imageshack.us/img42/8276/slantcomplete.png

+3
3

. , , , , 50% . .

+1

:

<UIElement.RenderTransform>
  <TransformGroup>
    <ScaleTransform ScaleX="2.0" />
    <RotateTransform Angle="-15" />
  </TransformGroup>
</UIElement.RenderTransform>
+1

The simplest solution would be to change the X and Y values ​​dynamically and not use RenderTransform. Why can't tilt calculations be used?

0
source

Source: https://habr.com/ru/post/1717896/


All Articles