0
我想多次使用DoubleAnimation。下面的代碼:多次使用WPF DoubleAnimation(ReSharper在XAML中顯示錯誤)
<Window x:Class="Project.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Window.Resources>
<DoubleAnimation x:Key="LeftAnimation" Storyboard.TargetProperty="(Canvas.Left)" From="0" To="100" />
<DoubleAnimation x:Key="TopAnimation" Storyboard.TargetProperty="(Canvas.Top)" From="0" To="100" />
</Window.Resources>
<Window.Triggers>
<EventTrigger RoutedEvent="Window.Loaded">
<BeginStoryboard>
<Storyboard Storyboard.TargetName="AnimatedBorder1">
<StaticResourceExtension ResourceKey="LeftAnimation" />
</Storyboard>
</BeginStoryboard>
<BeginStoryboard>
<Storyboard Storyboard.TargetName="AnimatedBorder2">
<StaticResourceExtension ResourceKey="LeftAnimation" />
<StaticResourceExtension ResourceKey="TopAnimation" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Window.Triggers>
<Canvas>
<Border x:Name="AnimatedBorder1" Background="Blue" Width="20" Height="20" />
<Border x:Name="AnimatedBorder2" Background="Red" Width="20" Height="20" />
</Canvas>
</Window>
的代碼工作正常,但ReSharper的強調LeftAnimation符合<StaticResourceExtension ResourceKey="LeftAnimation" />
說:「無效的資源類型:預計類型是‘TriggerCollection’,實際的類型是‘DoubleAnimation是’」
這真的是一個問題,或者這是ReSharper(版本9.2)中的錯誤?
謝謝您的回答,但我做什麼,如果我有一秒鐘的動畫,例如TopAnimation?在第一個故事板中,我只需要一個動畫,在另一個故事板中我需要兩個動畫。 (查看問題) – Pearson
@Pearson根據您的需要編輯。 – Ilan
感謝您的回答 – Pearson