Often when we consume data from the network or a local database, the values we retrieve aren't always in the appropriate format for user presentation, such as dates as we demonstrate in this recipe example. You have a property type of DateTime
, and you want to display it to the user's screen in a detailed form such as MM/dd/yyyy HH:mm:ss.fff
.
To achieve this in the following recipe, we are using a value converter.
Create a Visual Studio Blank App (Xamarin.Forms Portable) solution named
XamFormsValueConverter
, from the top menu File | New | Project….Right-click the
XamFormsValueConverter
portable class library and choose Add | Class…; name itNotifyPropertyChangedExtension.cs
and click Add.Make the newly created class static and add the contents like the following:
public static class NotifyPropertyChangedExtension { public static void Raise<T>(this PropertyChangedEventHandler handler, object sender, Expression<Func<T>> propertyExpression...