#803 – Specifying an Arbitrary Transform with a MatrixTransform
April 22, 2013 2 Comments
You can transform user interface elements using the ScaleTransform, RotateTransform, TranslateTransform and SkewTransform objects. Each of these transforms maps to a 3 x 3 transformation matrix that uses homogeneous coordinates to transform the element.
You can also specify any arbitrary transformation matrix directly, using the Matrix property of a MatrixTransform object. The Matrix property is set to a Matrix struct, containing the following properties: M11, M12, M21, M22, OffsetX, and OffsetY. This results in the transformation matrix:
<Label Background="LightCoral" Content="The Earth" Margin="5" HorizontalAlignment="Center"> <Label.LayoutTransform> <MatrixTransform> <MatrixTransform.Matrix> <Matrix M11="1.3" M12="0.1" M21="0.1" M22="1.2" OffsetX="5.0" OffsetY="6.0"/> </MatrixTransform.Matrix> </MatrixTransform> </Label.LayoutTransform> </Label>
Pingback: Dew Drop – April 22, 2013 (#1,532) | Alvin Ashcraft's Morning Dew
Pingback: #804 – Specifying a MatrixTransform as a Simple String | 2,000 Things You Should Know About WPF