title: Binding OneWayToSource - Strange Behavior
body: <p>I have done a buch of test with <code>Binding Mode = OneWayToSource</code> lately and I still don't know why certain things happen.</p>
  
  <p>As example I set a value on a <code>dependency property</code> in class constructor. Now when Binding is initalizing the <code>Target</code> property gets set to its default value. Means the <code>dependency property</code> gets set to <code>null</code> and I lose the value I initalized in <code>constructor</code>.</p>
  
  <p>Why is that happening? The <code>Binding Mode</code> is not working the way the name describes it. It shall only update the <code>Source</code> and not <code>Target</code></p>
  
  <p>Here is code:</p>
  
  <pre><code>public partial class MainWindow : Window
  {
      public MainWindow()
      {
          InitializeComponent();
          this.DataContext = new MyViewModel();
      }
  
      private void OnClick(object sender, RoutedEventArgs e)
      {
          this.DataContext = new MyViewModel();
      }
  }
  </code></pre>
  
  <p>This is XAML:</p>
  
  <pre><code>&lt;StackPanel&gt;
          &lt;local:MyCustomControl Txt="{Binding Str, Mode=OneWayToSource}"/&gt;
          &lt;Button Click="OnClick"/&gt;
  &lt;/StackPanel&gt;
  </code></pre>
  
  <p>This is MyCustomControl:</p>
  
  <pre><code>    public class MyCustomControl : Control
      {
          public static readonly DependencyProperty TxtProperty =
              DependencyProperty.Register("Txt", typeof(string), typeof(MyCustomControl), new UIPropertyMetadata(null));
  
          static MyCustomControl()
          {
              DefaultStyleKeyProperty.OverrideMetadata(typeof(MyCustomControl), new FrameworkPropertyMetadata(typeof(MyCustomControl)));
          }
  
          public MyCustomControl()
          {
             this.Txt = "123";
          }
  
          public string Txt
          {
             get { return (string)this.GetValue(TxtProperty); }
  
             set { this.SetValue(TxtProperty, value); }
          }
       }
  </code></pre>
  
  <p>This is ViewModel:</p>
  
  <pre><code>    public class MyViewModel : INotifyPropertyChanged
      {
          private string str;
  
          public string Str
          {
              get { return this.str; }
              set
              {
                  if (this.str != value)
                  {
                      this.str = value; this.OnPropertyChanged("Str");
                  }
              }
           }
  
          protected void OnPropertyChanged(string propertyName)
          {
              if (this.PropertyChanged != null &amp;&amp; propertyName != null)
              {
                  this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
              }
          }
  
          public event PropertyChangedEventHandler PropertyChanged;
       }
  </code></pre>