共用方式為


HOW TO:使用 MatrixTransform 建立自訂轉換

本範例示範如何使用 MatrixTransform 來轉換 (移動) Button 的位置、縮放及傾斜。

注意事項注意事項

使用 MatrixTransform 類別,建立 RotateTransformSkewTransformScaleTransformTranslateTransform 類別沒有提供的自訂轉換。

範例

<Page xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml" >
  <StackPanel Margin="20">
    <Canvas HorizontalAlignment="Left" Width="340" Height="240" >

      <Button MinWidth="100">Click
        <Button.RenderTransform>
          <MatrixTransform x:Name="myMatrixTransform">
            <MatrixTransform.Matrix >

              <!-- OffsetX and OffsetY specify the position of the button,
              M11 stretches it, and M12 skews it. -->
              <Matrix OffsetX="10" OffsetY="100" M11="3" M12="2"/>
            </MatrixTransform.Matrix>
          </MatrixTransform>
        </Button.RenderTransform>
      </Button>
    </Canvas>
  </StackPanel>
</Page>

請參閱

參考

MatrixTransform

Transform

概念

轉換概觀

WPF 中圖案和基本繪圖概觀

其他資源

轉換 HOW TO 主題