NativeConvertionContextAttribute

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 the customer should explicitly specify the kind of the property. This can be done with the NativeConvertionContextAttribute.

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