У меня есть стрелка блока, и я хочу, чтобы она мигала, просто залив ее зеленым цветом. Я хотел бы быть в состоянии остановить это также. У меня есть меню, вызываемое правой кнопкой мыши, чтобы запустить его и остановить.
Это то, что я имею до сих пор. Но я не могу понять, как это начать. Я пытался получить к нему доступ, но я получил ошибку:
All objects added to an IDictionary must have a
Key attribute or some other type of key associated with them. Line 11 Position 10.
Вот мой код xaml:
<ed:BlockArrow x:Name="ArrowLeft" Fill="Green" HorizontalAlignment="Left" Height="29" Margin="142,0,0,-3" Orientation="Left" Stroke="#FF13FF00" VerticalAlignment="Bottom" Width="39" />
<Window.Resources>
<Storyboard x:Name="Blink" AutoReverse="True" RepeatBehavior="Forever">
<ColorAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetName="ArrowLeft"
Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
<EasingColorKeyFrame KeyTime="00:00:01" Value="Green"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
Итак, в меню правой кнопки мыши, чтобы запустить его, у меня есть:
private void MenuItemLeft_Click(object sender, RoutedEventArgs e)
{
Storyboard blinkAnimation = TryFindResource("Blink") as Storyboard;
if (blinkAnimation != null)
{
blinkAnimation.Begin();
}
Есть ли лучший способ сделать это? или что я делаю не так?