Bug 41508 - Xamarin Form Andoird: Open datepicker from toolbaritem icon will crash application !!!
Summary: Xamarin Form Andoird: Open datepicker from toolbaritem icon will crash applic...
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.2.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Samantha Houts [MSFT]
Depends on:
Reported: 2016-06-04 05:06 UTC by Phat Nguyen
Modified: 2017-06-19 18:52 UTC (History)
5 users (show)

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

AppUI (31.91 KB, image/jpeg)
2016-06-04 05:06 UTC, Phat Nguyen
APP Crash (14.11 KB, image/jpeg)
2016-06-04 05:07 UTC, Phat Nguyen

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:

Description Phat Nguyen 2016-06-04 05:06:32 UTC
Created attachment 16195 [details]

I have 3 tabs inside tabbedpage (Tabs: DIspatchList, Info, Message). In "DispatchList" tab, I have an icon at toolbar for user click on it to display the datepicker. Info tab and Message tab are the same, and do not implement anything.

My issue: 
_ When user's at "DispatchList" tab, or go to "Info" tab and go back to "DispatchList" tab, and clicks on the icon: the datepicker will be displayed ok!
_ But when user swipe to "Message" tab and then go back to "DispatchList" tab, and click on the icon: the datepicker will not be displayed, and crash the application

Here is my images about my application:
APP Crash

This function will called when user click on the icon, and the application will crash when run at the line [datepicker.Focus()];:

private void DateToolBarItem_Clicked(object sender, EventArgs e)
      datepicker.IsEnabled = true;
      if (datepicker.IsFocused)
   catch (Exception Ex)

The exception message is: Object reference not set to an instance of an object

at Xamarin.Forms.Platform.Android.DatePickerRenderer.OnTextFieldClicked () [0x00007] in C:\BuildAgent3\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\Renderers\DatePickerRenderer.cs:114 
at Xamarin.Forms.Platform.Android.DatePickerRenderer.OnFocusChangeRequested (System.Object sender, Xamarin.Forms.FocusRequestArgs e) [0x00010] in C:\BuildAgent3\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\Renderers\DatePickerRenderer.cs:75 
at (wrapper delegate-invoke) System.EventHandler`1[Xamarin.Forms.VisualElement+FocusRequestArgs]:invoke_void_object_TEventArgs (object,Xamarin.Forms.VisualElement/FocusRequestArgs)
at Xamarin.Forms.VisualElement.Focus () [0x00021] in C:\BuildAgent3\work\aad494dc9bc9783\Xamarin.Forms.Core\VisualElement.cs:444 
at BGM.Views.DispatchsPage.DateToolBarItem_Clicked (System.Object sender, System.EventArgs e) [0x0002c] in D:\Mine\SystemGear\SGBG Mobile #1\V2\BGM\BGM\Views\DispatchsPage.xaml.cs:111
Comment 1 Phat Nguyen 2016-06-04 05:07:41 UTC
Created attachment 16196 [details]
APP Crash
Comment 2 Samantha Houts [MSFT] 2016-06-09 23:47:14 UTC
Thank you for taking the time to submit the bug. We tried to reproduce the issue you reported but were unable given the description. If you could please attach a reproduction to the bug by starting with a clean Xamarin.Forms project and adding just the code necessary to demonstrate the issue, we would very much appreciate it. 

For your convenience, we have created some reproduction best practices viewable here: https://gist.github.com/jassmith/92405c300e54a01dcc6d

Warm regards,
Xamarin Forms Team
Comment 3 Jose Manuel 2016-09-05 21:14:01 UTC
I have the same issue. This issue only reproduce in Android 5.0 or supperior
Comment 4 Samantha Houts [MSFT] 2016-09-30 18:31:14 UTC
@Jose Manuel

I have attempted to reproduce the issue as described with Android 5.0+, but with no luck. There must be another factor that is contributing to the cause. Do you have a sample project you could provide to help pinpoint the issue?

Warm regards,
Xamarin Forms Team
Comment 5 Samantha Houts [MSFT] 2017-06-19 18:52:24 UTC
Because we have not received a reply to our request for more information we are closing this issue. If you are still encountering this issue, please reopen the ticket with the requested information. Thanks!