Skip to content

Instantly share code, notes, and snippets.

@darthdeus darthdeus/PossibleAnimationBug.cs Secret
Last active Aug 29, 2015

Embed
What would you like to do?
public class TestPage : ContentPage
{
ListView list;
Button button;
public TestPage()
{
list = new ListView { ItemsSource = new[] { "hello", "world", "from", "xamarin", "forms" } };
button = new Button { Text = "Button" };
// The same behavior happens for both Absolute and Relative layout.
var layout = true ? Relative() : Absolute();
Animate();
Content = layout;
}
Layout Relative()
{
var layout = new RelativeLayout();
layout.Children.Add(list,
Constraint.RelativeToParent(p => p.X),
Constraint.RelativeToParent(p => p.Y),
Constraint.RelativeToParent(p => p.Width),
Constraint.RelativeToParent(p => p.Height)
);
layout.Children.Add(button,
Constraint.Constant(0),
Constraint.Constant(300));
return layout;
}
Layout Absolute()
{
var layout = new AbsoluteLayout { Children = { list, button } };
AbsoluteLayout.SetLayoutBounds(list, new Rectangle(0, 0, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
AbsoluteLayout.SetLayoutBounds(button, new Rectangle(0, 300, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
return layout;
}
async void Animate()
{
// Comment this delay out to see the bug
await Task.Delay(500);
button.LayoutTo(new Rectangle(100, 100, 100, 100), 1000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.