Animations with Exrin

98 views Asked by At

I'm looking to create animations with Exrin. I understand the MVVM framework aspect of it requires that the View owns the animations, but firing these animations initially is something I'm unsure of.

I do know that attaching to UI events is a bit of a hot button issue because then commands and events might exist together.

Does Exrin have a way of dealing with animations that isn't touched on in the documentation, should I attach animations to the UI Events, or should I go with something external like attached behaviors?

1

There are 1 answers

0
Adam On BEST ANSWER

Animations are a part of Xamarin Forms, and Exrin doesn't specifically deal with them, as you noted.

To trigger an animation, and keeping inline with an MVVM purist mentality, I would use a trigger.

As an example, you create a trigger, with just a class

public class BackgroundColorTrigger : TriggerAction<Entry>
{    
     protected override void Invoke(Entry sender)
     {
         sender.BackgroundColor = Color.Yellow;
     }
}

Of course you could run the animation from here. Then in XAML, you would do

// Add to Page Attributes (Above Trigger is in Namespace Mobile.Trigger)
xmlns:trigger="clr-namespace:Mobile.Trigger"

<Entry Text="{Binding EntryField}">   
    <Entry.Triggers>
        <EventTrigger Event="Focused">
            <trigger:BackgroundColorTrigger />
        </EventTrigger>
    </Entry.Triggers>
</Entry>

But change the trigger to what you need.

Animations are pure UI concepts, and hence stay in the View project in Exrin. XAML can directly trigger an animation, and the logic can be placed in a trigger.

Source: https://xamarinhelp.com/xamarin-forms-triggers-behaviors-effects/

Animations: https://xamarinhelp.com/custom-animations-in-xamarin-forms/