summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Xamarin.Forms.Core.UnitTests/FrameUnitTests.cs19
-rw-r--r--Xamarin.Forms.Core/Frame.cs9
-rw-r--r--Xamarin.Forms.Core/Layout.cs15
3 files changed, 33 insertions, 10 deletions
diff --git a/Xamarin.Forms.Core.UnitTests/FrameUnitTests.cs b/Xamarin.Forms.Core.UnitTests/FrameUnitTests.cs
index e7bf5974..f42dbb61 100644
--- a/Xamarin.Forms.Core.UnitTests/FrameUnitTests.cs
+++ b/Xamarin.Forms.Core.UnitTests/FrameUnitTests.cs
@@ -287,5 +287,20 @@ namespace Xamarin.Forms.Core.UnitTests
Assert.AreEqual (new Rectangle (80, 20, 100, 160), child.Bounds);
}
- }
-}
+
+ [Test]
+ public void SettingPaddingThroughStyle()
+ {
+ var frame = new Frame {
+ Style = new Style(typeof(Frame)) {
+ Setters = {
+ new Setter {Property = Layout.PaddingProperty, Value = 0}
+ }
+ }
+ };
+
+ Assert.AreEqual(new Thickness(0), frame.Padding);
+
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Core/Frame.cs b/Xamarin.Forms.Core/Frame.cs
index c93a642c..372a10c1 100644
--- a/Xamarin.Forms.Core/Frame.cs
+++ b/Xamarin.Forms.Core/Frame.cs
@@ -11,18 +11,21 @@ namespace Xamarin.Forms
public static readonly BindableProperty HasShadowProperty = BindableProperty.Create("HasShadow", typeof(bool), typeof(Frame), true);
- public static readonly BindableProperty CornerRadiusProperty =
- BindableProperty.Create(nameof(CornerRadius), typeof(float), typeof(Frame), -1.0f,
+ public static readonly BindableProperty CornerRadiusProperty = BindableProperty.Create(nameof(CornerRadius), typeof(float), typeof(Frame), -1.0f,
validateValue: (bindable, value) => ((float)value) == -1.0f || ((float)value) >= 0f);
readonly Lazy<PlatformConfigurationRegistry<Frame>> _platformConfigurationRegistry;
public Frame()
{
- Padding = new Size(20, 20);
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Frame>>(() => new PlatformConfigurationRegistry<Frame>(this));
}
+ internal override Thickness CreateDefaultPadding()
+ {
+ return 20d;
+ }
+
public bool HasShadow
{
get { return (bool)GetValue(HasShadowProperty); }
diff --git a/Xamarin.Forms.Core/Layout.cs b/Xamarin.Forms.Core/Layout.cs
index ac5e48b3..29565b7c 100644
--- a/Xamarin.Forms.Core/Layout.cs
+++ b/Xamarin.Forms.Core/Layout.cs
@@ -54,11 +54,11 @@ namespace Xamarin.Forms
{
public static readonly BindableProperty IsClippedToBoundsProperty = BindableProperty.Create("IsClippedToBounds", typeof(bool), typeof(Layout), false);
- public static readonly BindableProperty PaddingProperty = BindableProperty.Create("Padding", typeof(Thickness), typeof(Layout), default(Thickness), propertyChanged: (bindable, old, newValue) =>
- {
- var layout = (Layout)bindable;
- layout.UpdateChildrenLayout();
- });
+ public static readonly BindableProperty PaddingProperty = BindableProperty.Create("Padding", typeof(Thickness), typeof(Layout), default(Thickness),
+ propertyChanged: (bindable, old, newValue) => {
+ var layout = (Layout)bindable;
+ layout.UpdateChildrenLayout();
+ }, defaultValueCreator: (bindable) => ((Layout)bindable).CreateDefaultPadding());
static IList<KeyValuePair<Layout, int>> s_resolutionList = new List<KeyValuePair<Layout, int>>();
static bool s_relayoutInProgress;
@@ -90,6 +90,11 @@ namespace Xamarin.Forms
set { SetValue(PaddingProperty, value); }
}
+ internal virtual Thickness CreateDefaultPadding()
+ {
+ return default(Thickness);
+ }
+
internal ObservableCollection<Element> InternalChildren { get; } = new ObservableCollection<Element>();
internal override ReadOnlyCollection<Element> LogicalChildrenInternal