2010-04-05 6 views

risposta

15

È possibile ottenere il valore di rotazione facendo:

RotateTransform rotation = element.RenderTransform as RotateTransform; 
if (rotation != null) // Make sure the transform is actually a RotateTransform 
{ 
    double rotationInDegrees = rotation.Angle; 
    // Do something with the rotationInDegrees here, if needed... 
} 

Se si vuole fare solo un altro UIElement ruotano nello stesso modo, si può semplicemente assegnare lo stesso trasformare:

element2.RenderTransform = element.RenderTransform; 
3

È può denominare RotateTransform e quindi associare alle sue proprietà. Ad esempio, nel vostro elemento 'main' ui, si definisce la trasformazione come così:

<TextBlock Text="MainBox"> 
    <TextBlock.RenderTransform> 
    <RotateTransform Angle="20" 
        CenterX="50" 
        CenterY="50" 
        x:Name="m"/> 
    </TextBlock.RenderTransform> 
</TextBlock> 

Quindi è possibile associare a quella trasformarsi da un altro elemento:

<TextBlock Text="SecondBox"> 
    <TextBlock.RenderTransform> 
    <RotateTransform Angle="{Binding Angle, ElementName=m}" 
        CenterX="{Binding CenterX, ElementName=m}" 
        CenterY="{Binding CenterY, ElementName=m}"/> 
    </TextBlock.RenderTransform> 
</TextBlock> 
Problemi correlati