我在搞Silverlight試圖找出如何使它打勾,還有一件事情我似乎並沒有採取,關於故事板和獲取行爲按需推出。以下描述了一個藍色橢圓,它在Y軸上具有變換Y軸投影,因此當觸發時它看起來像是一個在其垂直軸上以3D旋轉的圓。該行爲在點擊橢圓時觸發。如果RepeatBehavior設置爲3x,則重複三次並停止。按需觸發Silverlight Storyboard行爲
我想弄明白的是每次點擊橢圓時如何使這種行爲重新激發,因爲行爲運行後第一次不會再次激發。我試圖讓它通過創建MouseLeftButtonDown事件,並與
Storyboard1.Begin();
填充它再次觸發,但這不執行任何操作。事實上,如果我在那裏設置斷點,它會執行,但不起作用。這裏是Xaml:
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" mc:Ignorable="d"
x:Class="UsingStoryboards.MainPage"
Width="640" Height="480">
<UserControl.Resources>
<Storyboard x:Name="Storyboard1" RepeatBehavior="3x">
<DoubleAnimation Duration="0:0:2" To="160" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="ellipse" d:IsOptimized="True"/>
</Storyboard>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<ei:ChangePropertyAction PropertyName="Background">
<ei:ChangePropertyAction.Value>
<SolidColorBrush Color="#FFE50D0D"/>
</ei:ChangePropertyAction.Value>
</ei:ChangePropertyAction>
</i:EventTrigger>
</i:Interaction.Triggers>
<Ellipse x:Name="ellipse" Fill="#FF000BF5" HorizontalAlignment="Left" Height="80" Margin="54,75,0,0" Stroke="Black" VerticalAlignment="Top" Width="80" MouseLeftButtonDown="ellipse_MouseLeftButtonDown">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonDown">
<ei:ControlStoryboardAction Storyboard="{StaticResource Storyboard1}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<Ellipse.Projection>
<PlaneProjection/>
</Ellipse.Projection>
</Ellipse>
</Grid>
</UserControl>
哇,沒錯,就是做到了。我在DoubleAnimation屬性中放置了一個From =「0」屬性,果然,現在每次點擊它時都會生成動畫!非常感謝! – Cyberherbalist 2010-10-01 22:14:39