summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2017-06-01 07:53:11 (GMT)
committerGitHub <noreply@github.com>2017-06-01 07:53:11 (GMT)
commit54322b98b4f7d43026ca51c813cc1fe320d153a8 (patch)
tree8422872912313fb24b6615958b38b1cb7adff0aa /Xamarin.Forms.Core
parent5adab7fe4e2024c7e9ab55f612f9c971e72eef9f (diff)
downloadxamarin-forms-54322b98b4f7d43026ca51c813cc1fe320d153a8.zip
xamarin-forms-54322b98b4f7d43026ca51c813cc1fe320d153a8.tar.gz
xamarin-forms-54322b98b4f7d43026ca51c813cc1fe320d153a8.tar.bz2
[C] use defaultValueCreator to set Frame default Padding (#943)
* [C] use defaultValueCreator to set Frame default Padding * [docs] update docs * change to internal * fix docs
Diffstat (limited to 'Xamarin.Forms.Core')
-rw-r--r--Xamarin.Forms.Core/Frame.cs9
-rw-r--r--Xamarin.Forms.Core/Layout.cs15
2 files changed, 16 insertions, 8 deletions
diff --git a/Xamarin.Forms.Core/Frame.cs b/Xamarin.Forms.Core/Frame.cs
index c93a642..372a10c 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 ac5e48b..29565b7 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