【发布时间】:2010-10-02 06:12:55
【问题描述】:
我正在搞乱 Silverlight,试图找出如何让它运行,关于情节提要和获得按需启动的行为,我似乎没有意识到一件事。下面描述了一个蓝色椭圆,它在 Y 轴上有一个变换 Y 轴投影,因此当被触发时,它看起来像一个在其垂直轴上以 3D 形式旋转的圆圈。单击椭圆时会触发该行为。如果 RepeatBehavior 设置为 3x,则重复 3 次并停止。
我想弄清楚的是如何在每次单击椭圆时重新触发此行为,因为在该行为第一次运行后它不会再次触发。我试图通过创建一个 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>
【问题讨论】:
标签: silverlight