Bug 42105 - DatePicker.MinimumDate & MaximumDate XML binding does not work (UWP project)
Summary: DatePicker.MinimumDate & MaximumDate XML binding does not work (UWP project)
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.0.0
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-06-23 11:48 UTC by Chris Stephens
Modified: 2016-07-07 21:10 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Chris Stephens 2016-06-23 11:48:18 UTC
When setting the DateTimePicker.MinimumDate and MaximumDate by way of binding to your model in xaml, they are not working. Setting them in code, then they work correctly.


This does not work....
 <DatePicker x:Name="orderDate" Date="{Binding OrderDate}"  >
              <DatePicker.Format>yyyy-MM-dd</DatePicker.Format>
              <DatePicker.MinimumDate Date="{Binding MinimumOrderDate}">
              </DatePicker.MinimumDate>
              <DatePicker.MaximumDate Date="{Binding MaximumOrderDate}">
              </DatePicker.MaximumDate>
            </DatePicker>


This DOES work....

 orderDate.SetValue(DatePicker.MinimumDateProperty, document.MinimumOrderDate);

..so does...

  orderDate.MinimumDate = document.MinimumOrderDate;



It's a UWP project, have not looked at iOS or Android.
Comment 1 E.Z. Hart [MSFT] 2016-07-07 21:10:53 UTC
Chris,

Try binding like this in XAML:

<DatePicker x:Name="orderDate" Date="{Binding OrderDate}" 
    MinimumDate="{Binding MinimumOrderDate}" 
    MaximumDate="{Binding MaximumOrderDate}">
    <DatePicker.Format>yyyy-MM-dd</DatePicker.Format>
</DatePicker>

That works for me on Android, iOS, and Windows UWP.