diff --git a/Perspex.UnitTests/Perspex.UnitTests.csproj b/Perspex.UnitTests/Perspex.UnitTests.csproj
index 02f45f0230..b07df6a6e8 100644
--- a/Perspex.UnitTests/Perspex.UnitTests.csproj
+++ b/Perspex.UnitTests/Perspex.UnitTests.csproj
@@ -35,6 +35,9 @@
4
+
+ ..\packages\Splat.1.1.1\lib\Net45\Splat.dll
+
False
diff --git a/Perspex.UnitTests/StyleTests.cs b/Perspex.UnitTests/StyleTests.cs
index 3bfde8e957..bf2d80d8b3 100644
--- a/Perspex.UnitTests/StyleTests.cs
+++ b/Perspex.UnitTests/StyleTests.cs
@@ -15,18 +15,33 @@ namespace Perspex.UnitTests
public class StyleTests
{
[TestMethod]
- public void Style_Should_Update_And_Restore_Value()
+ public void Style_With_Only_Type_Selector_Should_Update_Value()
{
- Style style = new Style
+ Style style = new Style(x => x.Select())
{
- Selector = x => x.Select().Class("foo"),
Setters = new[]
{
- new Setter
- {
- Property = TextBlock.TextProperty,
- Value = "Foo",
- }
+ new Setter(TextBlock.TextProperty, "Foo"),
+ },
+ };
+
+ TextBlock textBlock = new TextBlock
+ {
+ Text = "Original",
+ };
+
+ style.Attach(textBlock);
+ Assert.AreEqual("Foo", textBlock.Text);
+ }
+
+ [TestMethod]
+ public void Style_With_Class_Selector_Should_Update_And_Restore_Value()
+ {
+ Style style = new Style(x => x.Select().Class("foo"))
+ {
+ Setters = new[]
+ {
+ new Setter(TextBlock.TextProperty, "Foo"),
},
};
@@ -46,29 +61,19 @@ namespace Perspex.UnitTests
[TestMethod]
public void Later_Styles_Should_Override_Earlier()
{
- Style style1 = new Style
+ Style style1 = new Style(x => x.Select().Class("foo"))
{
- Selector = x => x.Select().Class("foo"),
Setters = new[]
{
- new Setter
- {
- Property = TextBlock.TextProperty,
- Value = "Foo",
- }
+ new Setter(TextBlock.TextProperty, "Foo"),
},
};
- Style style2 = new Style
+ Style style2 = new Style(x => x.Select().Class("foo"))
{
- Selector = x => x.Select().Class("foo"),
Setters = new[]
{
- new Setter
- {
- Property = TextBlock.TextProperty,
- Value = "Bar",
- }
+ new Setter(TextBlock.TextProperty, "Bar"),
},
};
diff --git a/Perspex.UnitTests/packages.config b/Perspex.UnitTests/packages.config
index 09f179893f..45110d2bb6 100644
--- a/Perspex.UnitTests/packages.config
+++ b/Perspex.UnitTests/packages.config
@@ -3,4 +3,5 @@
+
\ No newline at end of file
diff --git a/Perspex.Windows/Perspex.Windows.csproj b/Perspex.Windows/Perspex.Windows.csproj
index 104eec82fd..e8950efe2c 100644
--- a/Perspex.Windows/Perspex.Windows.csproj
+++ b/Perspex.Windows/Perspex.Windows.csproj
@@ -39,6 +39,9 @@
..\packages\SharpDX.DXGI.2.5.0\lib\net40\SharpDX.DXGI.dll
+
+ ..\packages\Splat.1.1.1\lib\Net45\Splat.dll
+
diff --git a/Perspex.Windows/packages.config b/Perspex.Windows/packages.config
index 9bf3829fc5..b2cc097609 100644
--- a/Perspex.Windows/packages.config
+++ b/Perspex.Windows/packages.config
@@ -8,5 +8,6 @@
+
\ No newline at end of file
diff --git a/Perspex/IBindingDescription.cs b/Perspex/IBindingDescription.cs
new file mode 100644
index 0000000000..3ade895491
--- /dev/null
+++ b/Perspex/IBindingDescription.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Perspex
+{
+ public interface IBindingDescription
+ {
+ string Description { get; }
+ }
+}
diff --git a/Perspex/Match.cs b/Perspex/Match.cs
index 73661f40c5..ca858ad1aa 100644
--- a/Perspex/Match.cs
+++ b/Perspex/Match.cs
@@ -28,5 +28,18 @@ namespace Perspex
get;
set;
}
+
+ public string Token
+ {
+ get;
+ set;
+ }
+
+ public override string ToString()
+ {
+ string result = (this.Previous != null) ? this.Previous.ToString() : string.Empty;
+ result += this.Token;
+ return result;
+ }
}
}
diff --git a/Perspex/Perspex.csproj b/Perspex/Perspex.csproj
index 35c78dac72..e2c4e172ca 100644
--- a/Perspex/Perspex.csproj
+++ b/Perspex/Perspex.csproj
@@ -76,6 +76,7 @@
+
@@ -108,6 +109,9 @@
+
+ ..\packages\Splat.1.1.1\lib\Portable-Net45+WinRT45+WP8\Splat.dll
+
..\packages\Rx-Core.2.1.30214.0\lib\Portable-Net45+WinRT45+WP8\System.Reactive.Core.dll
diff --git a/Perspex/PerspexObject.cs b/Perspex/PerspexObject.cs
index dc250c08b5..c9d5cc1ec3 100644
--- a/Perspex/PerspexObject.cs
+++ b/Perspex/PerspexObject.cs
@@ -14,6 +14,7 @@ namespace Perspex
using System.Reactive;
using System.Reactive.Linq;
using System.Reflection;
+ using Splat;
///
/// An object with support.
@@ -21,7 +22,7 @@ namespace Perspex
///
/// This class is analogous to DependencyObject in WPF.
///
- public class PerspexObject
+ public class PerspexObject : IEnableLogger
{
///
/// The registered properties by type.
@@ -168,6 +169,12 @@ namespace Perspex
{
binding.Dispose.Dispose();
this.bindings.Remove(property);
+
+ this.Log().Debug(string.Format(
+ "Cleared binding on {0}.{1} (#{2:x8})",
+ this.GetType().Name,
+ property.Name,
+ this.GetHashCode()));
}
}
@@ -177,6 +184,7 @@ namespace Perspex
/// The property.
public void ClearValue(PerspexProperty property)
{
+ // TODO: Implement this by using SetValue(UnsetValue).
Contract.Requires(property != null);
this.ClearBinding(property);
this.values.Remove(property);
@@ -194,6 +202,13 @@ namespace Perspex
if (this.bindings.TryGetValue(property, out binding))
{
this.bindings.Remove(property);
+
+ this.Log().Debug(string.Format(
+ "Extracted binding on {0}.{1} (#{2:x8})",
+ this.GetType().Name,
+ property.Name,
+ this.GetHashCode()));
+
return (IObservable