Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 如何使用MVVM启动动画?_Wpf_Mvvm - Fatal编程技术网

Wpf 如何使用MVVM启动动画?

Wpf 如何使用MVVM启动动画?,wpf,mvvm,Wpf,Mvvm,我正在使用WPF和MVVM模式转换现有的应用程序。 在我看来,我有不同的故事板 例1。加载应用程序时显示splashscreen 2.单击菜单切换按钮/单选按钮以显示滑入和滑出动画效果 3.视图中的不同元素具有不同的鼠标悬停效果 我将如何使用MVVM调用故事板,以及哪种方法是最好的?。为了显示鼠标悬停的效果,我们真的必须使用MVVM还是代码隐藏?对于问题1,我不确定您的要求,或者最好的方法,但有一个想法是您可以使用类似于下面第3条的代码,但将替换为 为了回答问题2,以下是当用户更改单选按钮时,我

我正在使用WPF和MVVM模式转换现有的应用程序。 在我看来,我有不同的故事板

例1。加载应用程序时显示splashscreen 2.单击菜单切换按钮/单选按钮以显示滑入和滑出动画效果 3.视图中的不同元素具有不同的鼠标悬停效果


我将如何使用MVVM调用故事板,以及哪种方法是最好的?。为了显示鼠标悬停的效果,我们真的必须使用MVVM还是代码隐藏?

对于问题1,我不确定您的要求,或者最好的方法,但有一个想法是您可以使用类似于下面第3条的代码,但将
替换为

为了回答问题2,以下是当用户更改单选按钮时,我如何开始编写故事板。这都是在XAML中实现的:

<CheckBox Content="Radio Button Option 1" >
     <i:Interaction.Triggers>
          <i:EventTrigger EventName="Checked">
               <im:ControlStoryboardAction Storyboard="{StaticResource NameOfStoryboardToRunOnCheck}"/>
          </i:EventTrigger>
          <i:EventTrigger EventName="Unchecked">
               <im:ControlStoryboardAction Storyboard="{StaticResource NameOfStoryboardToRunOnUnCheck}"/>
          </i:EventTrigger>
     </i:Interaction.Triggers>
</CheckBox>

对于问题3,这里是OnMouseOver的一个示例

<UserControl.Triggers>
     <EventTrigger RoutedEvent="Mouse.MouseEnter">
          <BeginStoryboard Storyboard="{StaticResource MouseOverStoryboard}" />
     </EventTrigger>
     <EventTrigger RoutedEvent="Mouse.MouseLeave">
          <BeginStoryboard Storyboard="{StaticResource MouseLeaveStoryboard}" />
     </EventTrigger>
</UserControl.Triggers>

对于问题1,我不确定您的要求,或者最好的方法,但有一个想法是您可以使用类似于下面第3条的代码,但将
替换为

为了回答问题2,以下是当用户更改单选按钮时,我如何开始编写故事板。这都是在XAML中实现的:

<CheckBox Content="Radio Button Option 1" >
     <i:Interaction.Triggers>
          <i:EventTrigger EventName="Checked">
               <im:ControlStoryboardAction Storyboard="{StaticResource NameOfStoryboardToRunOnCheck}"/>
          </i:EventTrigger>
          <i:EventTrigger EventName="Unchecked">
               <im:ControlStoryboardAction Storyboard="{StaticResource NameOfStoryboardToRunOnUnCheck}"/>
          </i:EventTrigger>
     </i:Interaction.Triggers>
</CheckBox>

对于问题3,这里是OnMouseOver的一个示例

<UserControl.Triggers>
     <EventTrigger RoutedEvent="Mouse.MouseEnter">
          <BeginStoryboard Storyboard="{StaticResource MouseOverStoryboard}" />
     </EventTrigger>
     <EventTrigger RoutedEvent="Mouse.MouseLeave">
          <BeginStoryboard Storyboard="{StaticResource MouseLeaveStoryboard}" />
     </EventTrigger>
</UserControl.Triggers>