diff --git a/Perspex.UnitTests/Perspex.UnitTests.csproj b/Perspex.UnitTests/Perspex.UnitTests.csproj
index 4fe2bb0fa6..33ff73f5aa 100644
--- a/Perspex.UnitTests/Perspex.UnitTests.csproj
+++ b/Perspex.UnitTests/Perspex.UnitTests.csproj
@@ -65,7 +65,6 @@
-
diff --git a/Perspex.UnitTests/PerspexObjectTests.cs b/Perspex.UnitTests/PerspexObjectTests.cs
index 8889fb2a05..b222fbc760 100644
--- a/Perspex.UnitTests/PerspexObjectTests.cs
+++ b/Perspex.UnitTests/PerspexObjectTests.cs
@@ -243,6 +243,18 @@ namespace Perspex.UnitTests
Assert.AreEqual("initial", target.GetValue(Class1.FooProperty));
}
+ [TestMethod]
+ public void Binding_NonGeneric_Sets_Current_Value()
+ {
+ Class1 target = new Class1();
+ Class1 source = new Class1();
+
+ source.SetValue(Class1.FooProperty, "initial");
+ target.SetValue((PerspexProperty)Class1.FooProperty, source.GetObservable(Class1.FooProperty));
+
+ Assert.AreEqual("initial", target.GetValue(Class1.FooProperty));
+ }
+
[TestMethod]
public void Binding_Sets_Subsequent_Value()
{
diff --git a/Perspex.UnitTests/PerspexPropertyTests.cs b/Perspex.UnitTests/PerspexPropertyTests.cs
index 3e1a24e6f2..76e4f5873c 100644
--- a/Perspex.UnitTests/PerspexPropertyTests.cs
+++ b/Perspex.UnitTests/PerspexPropertyTests.cs
@@ -22,7 +22,7 @@ namespace Perspex.UnitTests
false);
Assert.AreEqual("test", target.Name);
- Assert.AreEqual(typeof(string), target.ValueType);
+ Assert.AreEqual(typeof(string), target.PropertyType);
Assert.AreEqual(typeof(Class1), target.OwnerType);
Assert.AreEqual(false, target.Inherits);
}
diff --git a/Perspex.UnitTests/Style.cs b/Perspex.UnitTests/Style.cs
deleted file mode 100644
index 653e69defc..0000000000
--- a/Perspex.UnitTests/Style.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reactive.Disposables;
-using System.Reactive.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Perspex.Controls;
-
-namespace Perspex
-{
- public class Style
- {
- private bool applied;
-
- public Style()
- {
- this.Setters = new List();
- }
-
- public Func Selector
- {
- get;
- set;
- }
-
- public IEnumerable Setters
- {
- get;
- set;
- }
-
- public void Attach(Control control)
- {
- Match match = this.Selector(control);
-
- if (match != null)
- {
- List> o = new List>();
-
- while (match != null)
- {
- if (match.Observable != null)
- {
- o.Add(match.Observable);
- }
-
- match = match.Previous;
- }
-
- Observable.CombineLatest(o).Subscribe(x =>
- {
- if (x.All(y => y))
- {
- this.Apply(control);
- }
- else if (this.applied)
- {
- this.Unapply(control);
- }
- });
- }
- }
-
- private void Apply(Control control)
- {
- if (this.Setters != null)
- {
- foreach (Setter setter in this.Setters)
- {
- setter.Apply(control);
- }
- }
-
- this.applied = true;
- }
-
- private void Unapply(Control control)
- {
- if (this.Setters != null)
- {
- foreach (Setter setter in this.Setters)
- {
- setter.Unapply(control);
- }
-
- this.applied = false;
- }
- }
- }
-}
diff --git a/Perspex/PerspexObject.cs b/Perspex/PerspexObject.cs
index 9075e1ad80..dc250c08b5 100644
--- a/Perspex/PerspexObject.cs
+++ b/Perspex/PerspexObject.cs
@@ -10,6 +10,7 @@ namespace Perspex
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
+ using System.Linq.Expressions;
using System.Reactive;
using System.Reactive.Linq;
using System.Reflection;
@@ -42,8 +43,8 @@ namespace Perspex
///
/// The current bindings on this object.
///
- private Dictionary bindings =
- new Dictionary();
+ private Dictionary bindings =
+ new Dictionary();
///
/// Raised when a value changes on this object/
@@ -161,17 +162,17 @@ namespace Perspex
public void ClearBinding(PerspexProperty property)
{
Contract.Requires(property != null);
- IDisposable binding;
+ Binding binding;
if (this.bindings.TryGetValue(property, out binding))
{
- binding.Dispose();
+ binding.Dispose.Dispose();
this.bindings.Remove(property);
}
}
///
- /// Clears a value, including its bindings.
+ /// Clears a value, including its binding.
///
/// The property.
public void ClearValue(PerspexProperty property)
@@ -181,6 +182,46 @@ namespace Perspex
this.values.Remove(property);
}
+ ///
+ /// Clears a binding on a , returning the bound observable and
+ /// leaving the last bound value in place.
+ ///
+ /// The property.
+ public IObservable