我正在使用WPF,我無法實現動畫。WPF旋轉動畫
我有一個矩形,從x度旋轉,渲染變換的起點從0,0。 我想要這個矩形在2秒後從y度旋轉,渲染變換的原點從0,1。
當然,我想保留第二個動畫的矩形位置。
我的問題是當我更改rendertransform原點並應用第二個旋轉當前位置不保留,他從初始位置移動。
任何想法,我可以如何實現這一目標?
感謝您的幫助。
<Window x:Class="SimpleMove"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="OpenWWindow" Height="900" Width="900">
<Grid >
<Rectangle Name="rec1" Width="100" Height="400" Fill="DimGray" RenderTransformOrigin="0,0">
<Rectangle.RenderTransform>
<RotateTransform x:Name="Rec1_Rotate"/>
</Rectangle.RenderTransform>
</Rectangle>
<Button Width="45" Height="30" Name="Button1">Start
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Click">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard TargetProperty="Angle">
<DoubleAnimation Storyboard.TargetName="Rec1_Rotate" By="40" Duration="00:00:1" BeginTime="00:00:00"/>
<PointAnimation Storyboard.TargetName="rec1" Storyboard.TargetProperty="RenderTransformOrigin" To="0,1" Duration="00:00:0" BeginTime="00:00:02" />
<DoubleAnimation Storyboard.TargetName="Rec1_Rotate" By="-80" Duration="00:00:2" BeginTime="00:00:03"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Button.Triggers>
</Button>
</Grid>
</Window>
有些事情我不太瞭解你想做什麼。你能解釋一下嗎?根據我的理解,你試圖將矩形從原始點向左旋轉40°,然後將點移動到0,1,並且你希望它始終從那裏旋轉?你想讓它從第二個動畫矩形的不同角落旋轉嗎?只是尋求一些理想的結果的澄清。 – 2010-10-14 12:04:47
我就是這樣。我想用第一個動畫從第一個點開始旋轉。然後再從另一點移動,但保持先前的位置。我希望它更清晰 – 2010-10-15 12:01:34