[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
This commit is contained in:
Stephane Delcroix 2017-06-01 09:53:11 +02:00 коммит произвёл GitHub
Родитель 5adab7fe4e
Коммит 54322b98b4
3 изменённых файлов: 33 добавлений и 10 удалений

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

@ -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);
}
}
}

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

@ -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); }

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

@ -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