diff --git a/samples/BindingTest/MainWindow.paml b/samples/BindingTest/MainWindow.paml
index 739651b21e..bb60094494 100644
--- a/samples/BindingTest/MainWindow.paml
+++ b/samples/BindingTest/MainWindow.paml
@@ -1,22 +1,29 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ !BooleanString
+ !!BooleanString
+
-
-
-
-
-
-
-
-
- !BooleanString
- !!BooleanString
+
+
+
+
\ No newline at end of file
diff --git a/samples/BindingTest/ViewModels/MainWindowViewModel.cs b/samples/BindingTest/ViewModels/MainWindowViewModel.cs
index 8722568aee..02e8d9d65d 100644
--- a/samples/BindingTest/ViewModels/MainWindowViewModel.cs
+++ b/samples/BindingTest/ViewModels/MainWindowViewModel.cs
@@ -7,6 +7,7 @@ namespace BindingTest.ViewModels
public class MainWindowViewModel : ReactiveObject
{
private string _booleanString = "True";
+ private double _doubleValue = 5.0;
private string _stringValue = "Simple Binding";
public MainWindowViewModel()
@@ -35,6 +36,12 @@ namespace BindingTest.ViewModels
set { this.RaiseAndSetIfChanged(ref _booleanString, value); }
}
+ public double DoubleValue
+ {
+ get { return _doubleValue; }
+ set { this.RaiseAndSetIfChanged(ref _doubleValue, value); }
+ }
+
public string StringValue
{
get { return _stringValue; }
diff --git a/src/Markup/Perspex.Markup.Xaml/Binding/XamlBinding.cs b/src/Markup/Perspex.Markup.Xaml/Binding/XamlBinding.cs
index cb2c999f7a..a77b4b4c2a 100644
--- a/src/Markup/Perspex.Markup.Xaml/Binding/XamlBinding.cs
+++ b/src/Markup/Perspex.Markup.Xaml/Binding/XamlBinding.cs
@@ -29,7 +29,9 @@ namespace Perspex.Markup.Xaml.Binding
public void Bind(IObservablePropertyBag instance, PerspexProperty property)
{
- var subject = new ExpressionSubject(CreateExpressionObserver(instance, property));
+ var subject = new ExpressionSubject(
+ CreateExpressionObserver(instance, property),
+ property.PropertyType);
if (subject != null)
{
diff --git a/src/Markup/Perspex.Markup/Binding/ExpressionObserver.cs b/src/Markup/Perspex.Markup/Binding/ExpressionObserver.cs
index 2e76d58e24..e3141c5d4c 100644
--- a/src/Markup/Perspex.Markup/Binding/ExpressionObserver.cs
+++ b/src/Markup/Perspex.Markup/Binding/ExpressionObserver.cs
@@ -79,9 +79,43 @@ namespace Perspex.Markup.Binding
}
}
+ ///
+ /// Gets the type of the expression result or null if the expression could not be
+ /// evaluated.
+ ///
+ public Type ResultType
+ {
+ get
+ {
+ IncrementCount();
+
+ try
+ {
+ return (Leaf as PropertyAccessorNode)?.PropertyType;
+ }
+ finally
+ {
+ DecrementCount();
+ }
+ }
+ }
+
///
string IDescription.Description => Expression;
+ ///
+ /// Gets the leaf node.
+ ///
+ private ExpressionNode Leaf
+ {
+ get
+ {
+ var node = _node;
+ while (node.Next != null) node = node.Next;
+ return node;
+ }
+ }
+
///
protected override IDisposable SubscribeCore(IObserver