[Core] Fix Padding of Layout Issue (#2764) fixes #2763

This commit is contained in:
Seungkeun Lee 2018-06-08 05:20:17 +09:00 коммит произвёл Rui Marinho
Родитель 11b1496db5
Коммит b2a78b269b
3 изменённых файлов: 142 добавлений и 2 удалений

Просмотреть файл

@ -0,0 +1,139 @@
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
using Xamarin.Forms;
namespace Xamarin.Forms.Controls
{
// This test covers the issue reported in https://github.com/xamarin/Xamarin.Forms/issues/2763
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 2763,
"[Core] StakLayout Padding update issue", NavigationBehavior.PushAsync)]
public class Issue2763 : TestContentPage
{
protected override void Init()
{
StackLayout parentLayout1 = null;
StackLayout parentLayout2 = null;
StackLayout parentLayout3 = null;
StackLayout stackLayout = new StackLayout
{
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
BackgroundColor = Color.Blue,
Children =
{
new BoxView
{
Color = Color.Red,
HeightRequest = 100,
WidthRequest = 100,
}
}
};
ContentView contentView = new ContentView
{
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
BackgroundColor = Color.Blue,
Content =
new BoxView
{
Color = Color.Red,
HeightRequest = 100,
WidthRequest = 100,
}
};
FlexLayout flex = new FlexLayout
{
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
BackgroundColor = Color.Blue,
Children =
{
new BoxView
{
Color = Color.Red,
HeightRequest = 100,
WidthRequest = 100,
}
}
};
Slider paddingSlider = new Slider
{
HorizontalOptions = LayoutOptions.FillAndExpand,
Minimum = 0.0,
Maximum = 100.0,
};
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 });
// Build the page.
this.Padding = new Thickness(20);
this.Content = new StackLayout
{
Spacing = 20,
Children =
{
new StackLayout
{
Orientation = StackOrientation.Horizontal,
Children =
{
new Label
{
Text = "Padding"
},
paddingSlider,
}
},
new Button()
{
Text = "Force update",
Command = new Command(() =>
{
var boxview = new BoxView();
parentLayout1.Children.Add(boxview);
parentLayout1.Children.Remove(boxview);
parentLayout2.Children.Add(boxview);
parentLayout2.Children.Remove(boxview);
parentLayout3.Children.Add(boxview);
parentLayout3.Children.Remove(boxview);
})
},
new ScrollView
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
Content = new StackLayout
{
Spacing = 20,
Children =
{
(parentLayout1 = new StackLayout
{
Children = { new Label { Text = "StackLayout" }, stackLayout },
}),
(parentLayout2 = new StackLayout
{
Children = { new Label { Text = "ContentView" }, contentView }
}),
(parentLayout3 = new StackLayout
{
Children = { new Label { Text = "FlexLayout" }, flex }
})
}
}
}
}
};
}
}
}

Просмотреть файл

@ -253,6 +253,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Issue1415.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue2653.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue1942.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue2763.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue2247.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GroupListViewHeaderIndexOutOfRange.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue1760.cs" />
@ -910,4 +911,4 @@
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>
</Project>
</Project>

Просмотреть файл

@ -102,7 +102,7 @@ namespace Xamarin.Forms
void IPaddingElement.OnPaddingPropertyChanged(Thickness oldValue, Thickness newValue)
{
UpdateChildrenLayout();
InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
}
internal ObservableCollection<Element> InternalChildren { get; } = new ObservableCollection<Element>();