--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ContentPage
+ xmlns="http://xamarin.com/schemas/2014/forms"
+ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+ x:Class="Xamarin.Forms.Xaml.UnitTests.Gh5290"
+ NullableTime="{Binding Time, Mode=TwoWay}">
+</ContentPage>
--- /dev/null
+using System;
+using NUnit.Framework;
+using Xamarin.Forms.Core.UnitTests;
+
+namespace Xamarin.Forms.Xaml.UnitTests
+{
+ public class Gh5290VM
+ {
+ public TimeSpan? Time { get; set; }
+ }
+
+ public partial class Gh5290 : ContentPage
+ {
+ public static readonly BindableProperty NullableTimeProperty =
+ BindableProperty.Create("NullableTime", typeof(TimeSpan?), typeof(Gh5290), default(TimeSpan?));
+
+ public TimeSpan? NullableTime {
+ get => (TimeSpan?)GetValue(NullableTimeProperty);
+ set => SetValue(NullableTimeProperty, value);
+ }
+
+ public Gh5290() => InitializeComponent();
+ public Gh5290(bool useCompiledXaml)
+ {
+ //this stub will be replaced at compile time
+ }
+
+ [TestFixture]
+ class Tests
+ {
+ [SetUp] public void Setup() => Device.PlatformServices = new MockPlatformServices();
+ [TearDown] public void TearDown() => Device.PlatformServices = null;
+
+ [Test]
+ public void TwoWayBindingToNullable([Values(false, true)]bool useCompiledXaml)
+ {
+ var vm = new Gh5290VM { Time = TimeSpan.FromMinutes(42) };
+ var layout = new Gh5290(useCompiledXaml) { BindingContext = vm };
+ Assert.That(layout.NullableTime, Is.EqualTo(TimeSpan.FromMinutes(42)));
+
+ layout.SetValueFromRenderer(NullableTimeProperty, null);
+ Assert.That(vm.Time, Is.Null);
+ }
+ }
+ }
+}
\ No newline at end of file