Reputation: 21893
I am converting my exising Application using WPF and MVVM pattern. I have different storyboards in my view .
eg. 1. showing splashscreen while loading the app 2. while clicking Menu Toggle button/Radio Button to show the slide in and Slide out animation effect 3. And different mouseover effect for different elements available in the View.
How will i call the storyboard using MVVM and which is the best method?. To show the mouse over effect do we really have to use MVVM or code behind?
Upvotes: 1
Views: 1308
Reputation: 14438
For question 1, I'm not sure your requirements, or the best way to do this, but one idea is you can use code similar to #3 below, but replace <EventTrigger RoutedEvent="Mouse.MouseEnter">
with <EventTrigger RoutedEvent="Window.Loaded">
To answer question 2, Here is how I begin a storyboard when a user changes a radio button. This is all in 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>
For Question 3, here is an example of OnMouseOver
<UserControl.Triggers>
<EventTrigger RoutedEvent="Mouse.MouseEnter">
<BeginStoryboard Storyboard="{StaticResource MouseOverStoryboard}" />
</EventTrigger>
<EventTrigger RoutedEvent="Mouse.MouseLeave">
<BeginStoryboard Storyboard="{StaticResource MouseLeaveStoryboard}" />
</EventTrigger>
</UserControl.Triggers>
Upvotes: 1