Bug 54325 - Label's Text property not accepting DateTimeOffset type.
Summary: Label's Text property not accepting DateTimeOffset type.
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.3
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2017-03-31 09:39 UTC by Muthu kumaran.G
Modified: 2017-09-06 05:37 UTC (History)
4 users (show)

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

Label's Text property not accepting DateTimeOffset type. (265.91 KB, application/x-zip-compressed)
2017-03-31 09:39 UTC, Muthu kumaran.G

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 Muthu kumaran.G 2017-03-31 09:39:26 UTC
Created attachment 21091 [details]
Label's Text property not accepting DateTimeOffset type.


In my scenario, I want to bind the DateTimeOffset property to the text property of a label. On doing so am getting the following exception "Invalid Cast Exception " with the additional message "Object must implement IConvertible". I have attached the simple sample replicating the issue for your reference. Please look into and revert us.
Comment 1 Paul DiPietro [MSFT] 2017-03-31 14:30:53 UTC
It is trying to cast to a string value which I imagine is not being explicitly called, causing the invalid cast exception. Instead you can do something like this by adding another property to bind to:

public string StartDateString => StartDate.ToString();

or you can change the binding in your XAML:

Text="{Binding StartDate.DateTime}

This runs and shows the DateTime value of StartDate when running the project in an emulator.
Comment 2 Nishant Gaurav 2017-09-06 05:37:08 UTC
very informative to explore. Its lovely and really feels good to be in your posts. I love to read innovative posts like these. I am going to share these with all my friends and colleagues http://gtamoneyonline.com . Thanks for the amazing post. Hope to read many of  these.