更改坐标原点
通过 ScaleTransform 加上 TranslateTransform 来完成,下面的例子中是一个 1000 乘 1000 大小的 Canvas, 希望将其坐标原点移到中心,就是 500,500 处
<Canvas Height="1000" Width="1000">
<Canvas.Resources>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleY="-1"/>
</Setter.Value>
</Setter>
</Style>
</Canvas.Resources>
<Canvas.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleY="-1"/>
<TranslateTransform X="500" Y="500"/>
</TransformGroup>
</Canvas.RenderTransform>
<Line X1="0" Y1="0" X2="100" Y2="100" Stroke="Black" StrokeThickness="1"/>
<Line X1="90" Y1="100" X2="110" Y2="100" Stroke="Red" StrokeThickness="1"/>
<Line X1="100" Y1="90" X2="100" Y2="110" Stroke="Red" StrokeThickness="1"/>
<TextBlock Text="hello!" Canvas.Left="-100" Canvas.Top="0"/>
</Canvas>
-