diff --git a/Perspex.Base/Binding.cs b/Perspex.Base/Binding.cs index 88e2d96b65..93dd105187 100644 --- a/Perspex.Base/Binding.cs +++ b/Perspex.Base/Binding.cs @@ -7,7 +7,7 @@ namespace Perspex { using System; - using System.Reactive.Linq; + using System.Reactive; public enum BindingMode { @@ -18,7 +18,7 @@ namespace Perspex OneWayToSource, } - public class Binding : IObservable + public class Binding : ObservableBase, IDescription { public BindingMode Mode { @@ -44,6 +44,8 @@ namespace Perspex set; } + public string Description => string.Format("{0}.{1}", this.Source.GetType().Name, this.Property.Name); + public static Binding operator !(Binding binding) { return binding.WithMode(BindingMode.TwoWay); @@ -54,11 +56,6 @@ namespace Perspex return binding.WithMode(BindingMode.TwoWay); } - public IDisposable Subscribe(IObserver observer) - { - return this.Source.GetObservable(this.Property).Subscribe(observer); - } - public Binding WithMode(BindingMode mode) { this.Mode = mode; @@ -70,5 +67,10 @@ namespace Perspex this.Priority = priority; return this; } + + protected override IDisposable SubscribeCore(IObserver observer) + { + return this.Source.GetObservable(this.Property).Subscribe(observer); + } } } diff --git a/Perspex.Base/PriorityBindingEntry.cs b/Perspex.Base/PriorityBindingEntry.cs index 5e2ff6a018..1463f21a63 100644 --- a/Perspex.Base/PriorityBindingEntry.cs +++ b/Perspex.Base/PriorityBindingEntry.cs @@ -24,6 +24,8 @@ namespace Perspex this.Index = index; } + public IObservable Observable { get; private set; } + /// /// Gets a description of the binding. /// @@ -67,6 +69,7 @@ namespace Perspex throw new Exception("PriorityValue.Entry.Start() called more than once."); } + this.Observable = binding; this.Value = PerspexProperty.UnsetValue; if (binding is IDescription)