Skip to content

Instantly share code, notes, and snippets.

@hartez
Created October 3, 2017 22:07
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save hartez/1d168770dbe1e3ba790285abc537dffc to your computer and use it in GitHub Desktop.
Add gesture to off-screen view, animate it onto the screen, gesture still works
public class TranslatePage : ContentPage
{
public TranslatePage()
{
var layout = new RelativeLayout();
var tapGesture = new TapGestureRecognizer
{
Command = new Command(() => DisplayAlert("Box Tapped", "The box was tapped", "Cool, thanks."))
};
double boxSize = 100;
var box = new BoxView
{
HeightRequest = boxSize,
WidthRequest = boxSize,
BackgroundColor = Color.Red
};
layout.Children.Add(box,
Constraint.RelativeToParent(parent => -110),
Constraint.RelativeToParent(parent => - 110),
Constraint.Constant(boxSize), Constraint.Constant(boxSize));
Content = layout;
box.GestureRecognizers.Add(tapGesture);
var startGesture = new TapGestureRecognizer
{
Command = new Command(async () =>
{
await box.TranslateTo(200, 200);
await box.ScaleTo(2);
})
};
layout.GestureRecognizers.Add(startGesture);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment