New to Telerik UI for Xamarin? Download free 30-day trial

NativeConversionContextAttribute

Working with properties of type DateTime could be tricky because of the DateTime.Kind property. There is no straightforward way to map the kind while converting between CLR DateTime and Android/iOS dates. This is why sometimes you should explicitly specify the kind of the property. This can be done with the NativeConversionContextAttribute.

public class SourceItem : NotifyPropertyChangedBase
{
    private DateTime utc = new DateTime(2010, 1, 1, 0, 0, 0, DateTimeKind.Utc);

    [NativeConversionContext(DateTimeKind.Utc)]
    public DateTime Utc
    {
        get
        {
            return this.utc;
        }
        set
        {
            if (this.utc != value)
            {
                this.utc = value;
                this.OnPropertyChanged();
            }
        }
    }
}

See Also

In this article