Hello,
Welcome to our Microsoft Q&A platform!
What control is 'MessageLayout'? According to your posted code, it seems that you want to execute an animation when a view become visible\invisible. To achieve this, try creating a custom control to add a custom property and specify a PropertyChanged
event to detect the changes of the property.
Check the code:
public class CustomLayout : StackLayout
{
static CustomLayout layout;
public CustomLayout()
{
layout = this;
}
public static readonly BindableProperty IsSelectedProperty = BindableProperty.Create(nameof(IsSelected), typeof(bool), typeof(CustomLayout), null, propertyChanged: OnEventNameChanged);
public bool IsSelected
{
set => SetValue(IsSelectedProperty, value);
get => (bool)GetValue(IsSelectedProperty);
}
private static void OnEventNameChanged(BindableObject bindable, object oldValue, object newValue)
{
var value = (bool)newValue;
if (value)
{
layout.FadeTo(1, 5000, Easing.SpringOut);
}
else
{
layout.FadeTo(1, 5000, Easing.SpringIn);
}
}
}
Best Regards,
Jarvan Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.