-
-
Save darthdeus/4ae71f71997ae1430477 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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