title: WPF: What kind of binding should I use to associate a textbox to a dependency object declared in code?
body: <p>I have a DependencyObject class</p>
  
  <pre><code>public class TestDependency : DependencyObject
  {
      public static readonly DependencyProperty TestDateTimeProperty ...
  
      public DateTime TestDateTime {get... set..}
  }
  </code></pre>
  
  <p>my window is like this </p>
  
  <pre><code>public partial class MainWindow : Window{
  
      public TestDependency td;
      public MainWindow()
      {
          InitializeComponent();
          td = new TestDependency();
          td.TestDateTime = DateTime.Now;
      }
  }
  </code></pre>
  
  <p>If I wanna bind the TestDateTime property of MainWindow's dependency object td (public TestDependency td;) to a textbox in Xaml, how do I bind it? This is what I am doing now</p>
  
  <p><code>&lt;TextBlock Name="tb" Text="{Binding Source = td, Path=TestDateTime, TargetNullValue=novalue}"/&gt;</code></p>
  
  <p>It doesn't work at all. Anyone knows what I need to change?</p>