Partager via


Guide pratique pour utiliser matrixTransform pour créer des transformations personnalisées

Cet exemple montre comment utiliser un MatrixTransform pour traduire (déplacer) la position, l’étirement et l’asymétrie d’un Button.

Remarque

Utilisez la classe MatrixTransform pour créer des transformations personnalisées qui ne sont pas fournies par les classes RotateTransform, SkewTransform, ScaleTransformou TranslateTransform.

Exemple :

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://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>

Voir aussi