diff --git a/Perspex.Base/PerspexObject.cs b/Perspex.Base/PerspexObject.cs index 5fb57a7bac..f43bbcd9aa 100644 --- a/Perspex.Base/PerspexObject.cs +++ b/Perspex.Base/PerspexObject.cs @@ -574,6 +574,14 @@ namespace Perspex PriorityValue v; IDescription description = source as IDescription; + if (!this.IsRegistered(property)) + { + throw new InvalidOperationException(string.Format( + "Property '{0}' not registered on '{1}'", + property.Name, + this.GetType())); + } + if (!this.values.TryGetValue(property, out v)) { v = this.CreatePriorityValue(property); diff --git a/Tests/Perspex.Base.UnitTests/PerspexObjectTests.cs b/Tests/Perspex.Base.UnitTests/PerspexObjectTests.cs index 4577059964..0ceeaee616 100644 --- a/Tests/Perspex.Base.UnitTests/PerspexObjectTests.cs +++ b/Tests/Perspex.Base.UnitTests/PerspexObjectTests.cs @@ -355,6 +355,17 @@ namespace Perspex.Base.UnitTests Assert.Equal("initial", target.GetValue(Class1.FooProperty)); } + [Fact] + public void Bind_Throws_Exception_For_Unregistered_Property() + { + Class1 target = new Class1(); + + Assert.Throws(() => + { + target.Bind(Class2.BarProperty, Observable.Return("foo")); + }); + } + [Fact] public void Bind_Sets_Subsequent_Value() {