Rotate Shape in a Canvas : Canvas « Windows Presentation Foundation « C# / CSharp Tutorial






<Window x:Class="Drawing.RotateShape"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="RotateShape" Height="427" Width="332"
    >
  <Canvas>
    <Rectangle Width="80" Height="10" Stroke="Blue" Fill="Yellow" 
          Canvas.Left="100" Canvas.Top="100">      
    </Rectangle>

    <Rectangle Width="80" Height="10" Stroke="Blue" Fill="Yellow" 
      Canvas.Left="100" Canvas.Top="100">
      <Rectangle.RenderTransform>
        <RotateTransform Angle="25" />
      </Rectangle.RenderTransform>
    </Rectangle>

    <Rectangle Width="80" Height="10" Stroke="Blue" Fill="Yellow" 
          Canvas.Left="100" Canvas.Top="100">
      <Rectangle.RenderTransform>
        <RotateTransform Angle="50" />
      </Rectangle.RenderTransform>
    </Rectangle>

    <Rectangle Width="80" Height="10" Stroke="Blue" Fill="Yellow" 
      Canvas.Left="100" Canvas.Top="100">
      <Rectangle.RenderTransform>
        <RotateTransform Angle="75" />
      </Rectangle.RenderTransform>
    </Rectangle>

    <Rectangle Width="80" Height="10" Stroke="Blue" Fill="Yellow" 
      Canvas.Left="100" Canvas.Top="100">
      <Rectangle.RenderTransform>
        <RotateTransform Angle="100" />
      </Rectangle.RenderTransform>
    </Rectangle>

    <Rectangle Width="80" Height="10" Stroke="Blue" Fill="Yellow" 
          Canvas.Left="100" Canvas.Top="300">
    </Rectangle>

    <Rectangle Width="80" Height="10" Stroke="Blue" Fill="Yellow" 
      Canvas.Left="100" Canvas.Top="300">
      <Rectangle.RenderTransform>
        <RotateTransform Angle="25" CenterX="45" CenterY="5" />
      </Rectangle.RenderTransform>
    </Rectangle>

    <Rectangle Width="80" Height="10" Stroke="Blue" Fill="Yellow" 
      Canvas.Left="100" Canvas.Top="300">
      <Rectangle.RenderTransform>
        <RotateTransform Angle="50" CenterX="45" CenterY="5" />
      </Rectangle.RenderTransform>
    </Rectangle>
    
    <Rectangle Width="80" Height="10" Stroke="Blue" Fill="Yellow" 
      Canvas.Left="100" Canvas.Top="300">
      <Rectangle.RenderTransform>
        <RotateTransform Angle="75" CenterX="45" CenterY="5" />
      </Rectangle.RenderTransform>
    </Rectangle>
    
    <Rectangle Width="80" Height="10" Stroke="Blue" Fill="Yellow" 
      Canvas.Left="100" Canvas.Top="300">
      <Rectangle.RenderTransform>
        <RotateTransform Angle="100" CenterX="45" CenterY="5" />
      </Rectangle.RenderTransform>
    </Rectangle>
  </Canvas>


</Window>
WPF Rotate Shape








24.37.Canvas
24.37.1.Simple Canvas LayoutSimple Canvas Layout
24.37.2.Put Nested Canvas to TabItemPut Nested Canvas to TabItem
24.37.3.Positioning on a CanvasPositioning on a Canvas
24.37.4.Canvas without ViewboxCanvas without Viewbox
24.37.5.Animation target Canvas Left, TopAnimation target Canvas Left, Top
24.37.6.Pixel Not SnappedPixel Not Snapped
24.37.7.Rotate Shape in a CanvasRotate Shape in a Canvas
24.37.8.Canvas dependantCanvas dependant
24.37.9.Canvas.SetTopCanvas.SetTop
24.37.10.Canvas.SetBottomCanvas.SetBottom
24.37.11.Canvas.SetRightCanvas.SetRight
24.37.12.Canvas PreviewMouseDown action and MouseDown actionCanvas PreviewMouseDown action and MouseDown action
24.37.13.Create a Scrollable Canvas ControlCreate a Scrollable Canvas Control
24.37.14.Create a Zoomable Canvas ControlCreate a Zoomable Canvas Control
24.37.15.Set control position for CanvasSet control position for Canvas
24.37.16.Canvas Positioning Properties SampleCanvas Positioning Properties Sample
24.37.17.Get position on a Canvas with Canvas.GetLeftGet position on a Canvas with Canvas.GetLeft
24.37.18.Canvas size changed event