diff --git a/src/Perspex.Base/IPriorityValueOwner.cs b/src/Perspex.Base/IPriorityValueOwner.cs
new file mode 100644
index 0000000000..aa79864794
--- /dev/null
+++ b/src/Perspex.Base/IPriorityValueOwner.cs
@@ -0,0 +1,19 @@
+// Copyright (c) The Perspex Project. All rights reserved.
+// Licensed under the MIT license. See licence.md file in the project root for full license information.
+
+namespace Perspex
+{
+ ///
+ /// An owner of a .
+ ///
+ internal interface IPriorityValueOwner
+ {
+ ///
+ /// Called when a 's value changes.
+ ///
+ /// The source of the change.
+ /// The old value.
+ /// The new value.
+ void Changed(PriorityValue sender, object oldValue, object newValue);
+ }
+}
diff --git a/src/Perspex.Base/Perspex.Base.csproj b/src/Perspex.Base/Perspex.Base.csproj
index ae185b3abf..5718c9e217 100644
--- a/src/Perspex.Base/Perspex.Base.csproj
+++ b/src/Perspex.Base/Perspex.Base.csproj
@@ -54,6 +54,7 @@
+
diff --git a/src/Perspex.Base/PerspexObject.cs b/src/Perspex.Base/PerspexObject.cs
index 32f8eedc91..e787c97f57 100644
--- a/src/Perspex.Base/PerspexObject.cs
+++ b/src/Perspex.Base/PerspexObject.cs
@@ -21,7 +21,7 @@ namespace Perspex
///
/// This class is analogous to DependencyObject in WPF.
///
- public class PerspexObject : IPerspexObject, IPerspexObjectDebug, INotifyPropertyChanged
+ public class PerspexObject : IPerspexObject, IPerspexObjectDebug, INotifyPropertyChanged, IPriorityValueOwner
{
///
/// Maintains a list of direct property binding subscriptions so that the binding source
@@ -477,6 +477,34 @@ namespace Perspex
}
}
+ ///
+ void IPriorityValueOwner.Changed(PriorityValue sender, object oldValue, object newValue)
+ {
+ var property = sender.Property;
+ var priority = (BindingPriority)sender.ValuePriority;
+
+ oldValue = (oldValue == PerspexProperty.UnsetValue) ?
+ GetDefaultValue(property) :
+ oldValue;
+ newValue = (newValue == PerspexProperty.UnsetValue) ?
+ GetDefaultValue(property) :
+ newValue;
+
+ if (!Equals(oldValue, newValue))
+ {
+ RaisePropertyChanged(property, oldValue, newValue, priority);
+
+ Logger.Verbose(
+ LogArea.Property,
+ this,
+ "{Property} changed from {$Old} to {$Value} with priority {Priority}",
+ property,
+ oldValue,
+ newValue,
+ priority);
+ }
+ }
+
///
Delegate[] IPerspexObjectDebug.GetPropertyChangedSubscribers()
{
@@ -604,34 +632,10 @@ namespace Perspex
PriorityValue result = new PriorityValue(
this,
- property.Name,
+ property,
property.PropertyType,
validate2);
- result.Changed.Subscribe(x =>
- {
- object oldValue = (x.Item1 == PerspexProperty.UnsetValue) ?
- GetDefaultValue(property) :
- x.Item1;
- object newValue = (x.Item2 == PerspexProperty.UnsetValue) ?
- GetDefaultValue(property) :
- x.Item2;
-
- if (!Equals(oldValue, newValue))
- {
- RaisePropertyChanged(property, oldValue, newValue, (BindingPriority)result.ValuePriority);
-
- Logger.Verbose(
- LogArea.Property,
- this,
- "{Property} changed from {$Old} to {$Value} with priority {Priority}",
- property,
- oldValue,
- newValue,
- (BindingPriority)result.ValuePriority);
- }
- });
-
return result;
}
diff --git a/src/Perspex.Base/PriorityValue.cs b/src/Perspex.Base/PriorityValue.cs
index 7e10c6ca72..5a1ae7a4e0 100644
--- a/src/Perspex.Base/PriorityValue.cs
+++ b/src/Perspex.Base/PriorityValue.cs
@@ -20,20 +20,16 @@ namespace Perspex
/// represent higher priorites. The current is selected from the highest
/// priority binding that doesn't return . Where there
/// are multiple bindings registered with the same priority, the most recently added binding
- /// has a higher priority. Each time the value changes, the observable is
- /// fired with the old and new values.
+ /// has a higher priority. Each time the value changes, the
+ /// method on the
+ /// owner object is fired with the old and new values.
///
internal class PriorityValue
{
///
/// The owner of the object.
///
- private readonly PerspexObject _owner;
-
- ///
- /// The name of the property.
- ///
- private readonly string _name;
+ private readonly IPriorityValueOwner _owner;
///
/// The value type.
@@ -45,11 +41,6 @@ namespace Perspex
///
private readonly Dictionary _levels = new Dictionary();
- ///
- /// The changed observable.
- ///
- private readonly Subject> _changed = new Subject>();
-
///
/// The current value.
///
@@ -64,17 +55,17 @@ namespace Perspex
/// Initializes a new instance of the class.
///
/// The owner of the object.
- /// The name of the property.
+ /// The property that the value represents.
/// The value type.
/// An optional validation function.
public PriorityValue(
- PerspexObject owner,
- string name,
+ IPriorityValueOwner owner,
+ PerspexProperty property,
Type valueType,
Func