{
protected override void Init()
{
+ Title = "Padding update issue";
StackLayout parentLayout1 = null;
StackLayout parentLayout2 = null;
StackLayout parentLayout3 = null;
+ StackLayout parentLayout4 = null;
StackLayout stackLayout = new StackLayout
{
}
}
};
+ StackLayout stackLayout2 = new StackLayout
+ {
+ HorizontalOptions = LayoutOptions.FillAndExpand,
+ VerticalOptions = LayoutOptions.FillAndExpand,
+ BackgroundColor = Color.Blue,
+ Children =
+ {
+ new BoxView
+ {
+ HorizontalOptions = LayoutOptions.Start,
+ Color = Color.Red,
+ HeightRequest = 100,
+ WidthRequest = 100,
+ }
+ }
+ };
ContentView contentView = new ContentView
{
stackLayout.SetBinding(Forms.Layout.PaddingProperty, new Binding() { Path = "Value", Source = paddingSlider });
contentView.SetBinding(Forms.Layout.PaddingProperty, new Binding() { Path = "Value", Source = paddingSlider });
flex.SetBinding(Forms.Layout.PaddingProperty, new Binding() { Path = "Value", Source = paddingSlider });
+ stackLayout2.SetBinding(Forms.Layout.PaddingProperty, new Binding() { Path = "Value", Source = paddingSlider });
// Build the page.
this.Padding = new Thickness(20);
parentLayout2.Children.Remove(boxview);
parentLayout3.Children.Add(boxview);
parentLayout3.Children.Remove(boxview);
+ parentLayout4.Children.Add(boxview);
+ parentLayout4.Children.Remove(boxview);
})
},
new ScrollView
Spacing = 20,
Children =
{
+ (parentLayout4 = new StackLayout
+ {
+ HeightRequest = 200,
+ Children = { new Label { Text = "StackLayout2" }, stackLayout2 },
+ }),
(parentLayout1 = new StackLayout
{
Children = { new Label { Text = "StackLayout" }, stackLayout },
stack.Layout (new Rectangle (0, 0, 100, 100));
}
+
+ [Test]
+ public void PaddingResizeTest()
+ {
+ var child = new BoxView
+ {
+ IsPlatformEnabled = true,
+ WidthRequest = 20,
+ HeightRequest = 20,
+ };
+
+ var innerStack = new StackLayout
+ {
+ HorizontalOptions = LayoutOptions.Center,
+ VerticalOptions = LayoutOptions.Center,
+ IsPlatformEnabled = true,
+ Children = { child }
+ };
+
+ var outterLayout = new StackLayout
+ {
+ HorizontalOptions = LayoutOptions.FillAndExpand,
+ VerticalOptions = LayoutOptions.FillAndExpand,
+ IsPlatformEnabled = true,
+ Platform = new UnitPlatform(),
+ Children = { innerStack }
+ };
+
+ outterLayout.Layout(new Rectangle(0, 0, 100, 100));
+ var beforeSize = innerStack.Bounds.Size;
+ innerStack.Padding = new Thickness(30);
+ var afterSize = innerStack.Bounds.Size;
+ Assert.AreNotEqual(beforeSize, afterSize, "Padding was grow, so Size should be bigger");
+ }
+
+ [Test]
+ public void PaddingChildRelayoutTest()
+ {
+ var child = new BoxView
+ {
+ IsPlatformEnabled = true,
+ WidthRequest = 20,
+ HeightRequest = 20,
+ };
+
+ var innerStack = new StackLayout
+ {
+ HorizontalOptions = LayoutOptions.FillAndExpand,
+ VerticalOptions = LayoutOptions.FillAndExpand,
+ IsPlatformEnabled = true,
+ Children = { child }
+ };
+
+ var outterLayout = new StackLayout
+ {
+ HorizontalOptions = LayoutOptions.FillAndExpand,
+ VerticalOptions = LayoutOptions.FillAndExpand,
+ IsPlatformEnabled = true,
+ Platform = new UnitPlatform(),
+ Children = { innerStack }
+ };
+
+ outterLayout.Layout(new Rectangle(0, 0, 100, 100));
+ var before = child.Bounds;
+ innerStack.Padding = new Thickness(30);
+ var after = child.Bounds;
+ Assert.AreNotEqual(before, after, "child should be moved within padding size");
+ }
}
}