diff options
Diffstat (limited to 'Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1758.cs')
-rw-r--r-- | Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1758.cs | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1758.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1758.cs new file mode 100644 index 00000000..0afd2ebb --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1758.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using Xamarin.Forms.CustomAttributes; + +namespace Xamarin.Forms.Controls +{ + [Preserve (AllMembers=true)] + [Issue (IssueTracker.Github, 1758, "LayoutTo needs to be smarted about using layout specific API calls", PlatformAffected.Android | PlatformAffected.iOS | PlatformAffected.WinPhone)] + public class Issue1758 : ContentPage + { + ListView _list; + Button _button; + + public Issue1758() + { + _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, + Forms.Constraint.RelativeToParent(p => p.X), + Forms.Constraint.RelativeToParent(p => p.Y), + Forms.Constraint.RelativeToParent(p => p.Width), + Forms.Constraint.RelativeToParent(p => p.Height) + ); + + layout.Children.Add(_button, + Forms.Constraint.Constant(0), + Forms.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); + } + } +}
\ No newline at end of file |