Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

[WinPhone] DatePicker bug/best practice

$
0
0

Not sure if this is a proper bug, or should merely be a note of caution/best practice.

I've confirmed this in WinPhone under XForms 1.4.4.6392, but NOT Android. I suspect this is because Android uses a pop-up, while WinPhone displays an interstitial page (modal?) and the OS treats modals like proper pages.

To replicate this, add a page with a DatePicker. Set the date of the DatePicker in an overridden OnAppearing method. You cannot change the date as the OnAppearing method will be called every time you select a new date.

This is what you OnAppearing should look like:

protected override void OnAppearing()
{
    base.OnAppearing();

    MyDatePicker.Date = DateTime.Today;
}

Every time you change the date, it will reset to today.

The issue is, we should be setting data after the controls have loaded. The lack of a Loaded method means OnAppearing is the closest analogue. This bug means OnAppearing is an unreliable tool for avoiding potential race conditions of loading as you can easily create other problems.


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>