Browse Source

Implemented OneWayToSource binding.

Steven Kirk 10 years ago
parent
commit
8457645eb4

+ 5 - 2
samples/BindingTest/MainWindow.paml

@@ -1,6 +1,9 @@
 <Window xmlns="https://github.com/perspex">
-  <StackPanel Margin="18">
+  <StackPanel Margin="18" Gap="4">
     <TextBlock Text="{Binding SimpleBinding}"/>
-    <TextBox Watermark="Simple Binding" Text="{Binding SimpleBinding}"/>
+    <TextBox Watermark="Two Way" Text="{Binding SimpleBinding}"/>
+    <TextBox Watermark="One Way" Text="{Binding SimpleBinding, Mode=OneWay}"/>
+    <TextBox Watermark="One Time" Text="{Binding SimpleBinding, Mode=OneTime}"/>
+    <TextBox Watermark="One Way To Source" Text="{Binding SimpleBinding, Mode=OneWayToSource}"/>
   </StackPanel>
 </Window>

+ 2 - 1
src/Markup/Perspex.Markup.Xaml/DataBinding/XamlBinding.cs

@@ -58,7 +58,8 @@ namespace Perspex.Markup.Xaml.DataBinding
                 case BindingMode.OneTime:
                     throw new NotImplementedException();
                 case BindingMode.OneWayToSource:
-                    throw new NotImplementedException();
+                    Target.GetObservable(TargetProperty).Subscribe(new ExpressionSubject(observable));
+                    break;
             }
         }
     }

+ 1 - 1
src/Perspex.Base/BindingDescriptor.cs

@@ -27,7 +27,7 @@ namespace Perspex
         TwoWay,
 
         /// <summary>
-        /// Copies the target to the source one time and then disposes of the binding.
+        /// Updates the target when the application starts or when the data context changes.
         /// </summary>
         OneTime,