Animations
Animations and focus are specified by accessing the underlying Xamarin.Forms control and using Xamarin.Forms animation specifications. The underlying control is usually accessed via a ViewRef
, akin to a ref
in HTML/JavaScript and React.
A
ViewRef
must have a sufficient scope that it lives long enough, e.g. a global scope or the scope of the model. TheViewRef
can be held in the model itself if necessary.Initially
ViewRef
are empty. They will only be populated after theview
function has been called and its results applied to the visual display.
For example, the following shows the creation of a ViewRef
and associating it with a particular element:
The underlying control can also be accessed by using the created
handler:
NOTE: A
ViewRef
only holds a weak handle to the underlying control. TheValue
property may thus fail if the underlying control has been collected. As a result it is often sensible to use theTryValue
property which returns an option.
Animations
Animations are specified by using a Xamarin.Forms animation specification on the underlying control, e.g.
Animations in Xamarin.Forms specify tasks. These are ignorable if the animation is simple. Composite animations must compose tasks, either by using async { ...}
and Async.AwaitTask
and Async.StartAsTask
, or by using task { ... }
from the F# community TaskBuilder
library.
Examples of custom tasks are shown in C# syntax in Animation in Xamarin.Forms.
Last updated