我有這個觸發設置在LoadingAnimation.xaml動畫:WPF故事板觸發在C#
<UserControl.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard x:Name="ProgressAnimation_BeginStoryboard" Storyboard="{StaticResource ProgressAnimation}"/>
</EventTrigger>
</UserControl.Triggers>
在我MainWindow.xaml,我有這樣的一個網格內:
<control:LoadingAnimation x:Name="loadingAnimation" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="0" Grid.Row="7" Grid.ColumnSpan="2" />
我明白那我就可以開始用下面的代碼的故事板:
Storyboard storyboard = Application.Current.MainWindow.FindResource("ProgressAnimation") as Storyboard;
storyboard.Begin();
但我怎麼可以用「FindResource()時,我的故事板是在DIF不同階級?
相關帖子:http://stackoverflow.com/questions/3755651/call-a-storyboard-declared-in-xaml-from-c-sharp – har07
你的'Storyboard'聲明在哪裏? –
它在加載動畫中: –