From 8233f4df185516db9a469611c737efc582c4311c Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 16 Feb 2016 23:10:33 +0100 Subject: [PATCH] Support default binding mode on direct properties. --- src/Perspex.Base/DirectProperty.cs | 6 ++++-- src/Perspex.Base/PerspexProperty.cs | 7 +++++-- tests/Perspex.Base.UnitTests/DirectPropertyTests.cs | 6 +++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Perspex.Base/DirectProperty.cs b/src/Perspex.Base/DirectProperty.cs index c926f28240..7ae19ec520 100644 --- a/src/Perspex.Base/DirectProperty.cs +++ b/src/Perspex.Base/DirectProperty.cs @@ -24,11 +24,13 @@ namespace Perspex /// The name of the property. /// Gets the current value of the property. /// Sets the value of the property. May be null. + /// The property metadata. public DirectProperty( string name, Func getter, - Action setter = null) - : base(name, typeof(TOwner), new PropertyMetadata()) + Action setter, + PropertyMetadata metadata) + : base(name, typeof(TOwner), metadata) { Contract.Requires(getter != null); diff --git a/src/Perspex.Base/PerspexProperty.cs b/src/Perspex.Base/PerspexProperty.cs index 4c0b6fd724..8998627849 100644 --- a/src/Perspex.Base/PerspexProperty.cs +++ b/src/Perspex.Base/PerspexProperty.cs @@ -342,16 +342,19 @@ namespace Perspex /// The name of the property. /// Gets the current value of the property. /// Sets the value of the property. + /// The default binding mode for the property. /// A public static DirectProperty RegisterDirect( string name, Func getter, - Action setter = null) + Action setter = null, + BindingMode defaultBindingMode = BindingMode.OneWay) where TOwner : IPerspexObject { Contract.Requires(name != null); - var result = new DirectProperty(name, getter, setter); + var metadata = new PropertyMetadata(defaultBindingMode); + var result = new DirectProperty(name, getter, setter, metadata); PerspexPropertyRegistry.Instance.Register(typeof(TOwner), result); return result; } diff --git a/tests/Perspex.Base.UnitTests/DirectPropertyTests.cs b/tests/Perspex.Base.UnitTests/DirectPropertyTests.cs index 68e1c62cf3..9e23e59f80 100644 --- a/tests/Perspex.Base.UnitTests/DirectPropertyTests.cs +++ b/tests/Perspex.Base.UnitTests/DirectPropertyTests.cs @@ -30,7 +30,11 @@ namespace Perspex.Base.UnitTests [Fact] public void IsDirect_Property_Returns_True() { - var target = new DirectProperty("test", o => null); + var target = new DirectProperty( + "test", + o => null, + null, + new PropertyMetadata()); Assert.True(target.IsDirect); }