2010-04-05 11 views

Odpowiedz

15

można uzyskać wartość obrotów wykonując:

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... 
} 

Jeśli chcesz tylko dokonać innego UIElement obracają się w taki sam sposób, można po prostu przypisać tego samego przekształcenia:

element2.RenderTransform = element.RenderTransform; 
3

You można nazwać RotateTransform, a następnie powiązać z jego właściwościami. Na przykład, w „głównym” elementu interfejsu, można zdefiniować jako transformacji tak:

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

Następnie można wiązać że przekształcać od innego elementu:

<TextBlock Text="SecondBox"> 
    <TextBlock.RenderTransform> 
    <RotateTransform Angle="{Binding Angle, ElementName=m}" 
        CenterX="{Binding CenterX, ElementName=m}" 
        CenterY="{Binding CenterY, ElementName=m}"/> 
    </TextBlock.RenderTransform> 
</TextBlock> 
Powiązane problemy