[C] use picker creation date as default Date (#944)

* [C] use picker creation date as default Date

* fix test
This commit is contained in:
Stephane Delcroix 2017-06-01 09:33:38 +02:00 коммит произвёл GitHub
Родитель 6e732fbe74
Коммит 5adab7fe4e
2 изменённых файлов: 5 добавлений и 3 удалений

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

@ -162,7 +162,7 @@ namespace Xamarin.Forms.Core.UnitTests
{
var datePicker = new DatePicker ();
Assert.DoesNotThrow (() => datePicker.SetValue (DatePicker.DateProperty, null));
Assert.AreEqual (DatePicker.DateProperty.DefaultValue, datePicker.Date);
Assert.AreEqual (DateTime.Today, datePicker.Date);
}
[Test]

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

@ -8,8 +8,10 @@ namespace Xamarin.Forms
{
public static readonly BindableProperty FormatProperty = BindableProperty.Create(nameof(Format), typeof(string), typeof(DatePicker), "d");
public static readonly BindableProperty DateProperty = BindableProperty.Create(nameof(Date), typeof(DateTime), typeof(DatePicker), DateTime.Today, BindingMode.TwoWay, coerceValue: CoerceDate,
propertyChanged: DatePropertyChanged);
public static readonly BindableProperty DateProperty = BindableProperty.Create(nameof(Date), typeof(DateTime), typeof(DatePicker), default(DateTime), BindingMode.TwoWay,
coerceValue: CoerceDate,
propertyChanged: DatePropertyChanged,
defaultValueCreator: (bindable) => DateTime.Today);
public static readonly BindableProperty MinimumDateProperty = BindableProperty.Create(nameof(MinimumDate), typeof(DateTime), typeof(DatePicker), new DateTime(1900, 1, 1),
validateValue: ValidateMinimumDate, coerceValue: CoerceMinimumDate);