Warning, noob alert!
In a Forms project content page I have a label that when clicked, should start an animation on another visual element on the page. While I could easily do this in code behind, I am trying to stay true to the MVVM architecture, and want to have as little code behind as possible. For example, I can hook up the label to a command, like this:
<Label Text="Tap me!">
<Label.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding TapCommand}"
CommandParameter="Param1" />
</Label.GestureRecognizers>
</Label>
I have another element, let's simplify it to be a content view with a label inside. When the TapCommand is executed, I want this to fly over the screen:
<ContentView>
<Label Text="I'm flying!" />
</ContentView>
Tapping the first label will start the TapCommand, but how to start the animation from there? I don't want to violate the MVVM principles by bringing view elements into my view model. I am thinking maybe I can use behaviors to solve it, by creating a behavior that will do the animation, and adding it to the conten view. But from the samples I have seen on behaviors, they seem to be connected to events on the attached control (e.g. like the Entry sample, where behavior is triggered by the TextChanged event, performing some validation and setting red color if not valid). What throws me off here, is that the event triggering the animation is external to the animated control, so how do I connect the dots here? How can the TapCommand trigger a behavior on the ContentView when the ContentView has no events? Custom event? Or maybe behaviors are not the way to go?
Any help appreciated!