title: Create a proxy for a dependency property
body: <p>I am trying to create a simple dependency property proxy. I made a custom control, it's a file picker, which is made off a textbox (name: <code>"TextBox_FilePath"</code>) and a button showing the open file dialog.</p>
  
  <p>As I am making a reusable control I'd like it to have a <code>"SelectedFilePath"</code> property. As the <code>Text</code> property seems to be perfect for my control to be the <code>"SelectedFilePath"</code> property, I'd just like to proxy these dependency property.</p>
  
  <p>The first approach I made was:</p>
  
  <pre><code>public static readonly DependencyProperty SelectedFilePathProperty = TextBox.TextProperty;
  
  public string SelectedFilePath
  {
      get { return (string) this.TextBox_FilePath.GetValue(SelectedFilePathProperty); }
      set { this.TextBox_FilePath.SetValue(SelectedFilePathProperty, value); }
  }
  </code></pre>
  
  <p>which worked, but throwed an exception when trying to bind to that property. Then I came off with:</p>
  
  <pre><code>public static readonly DependencyProperty SelectedFilePathProperty =
      DependencyProperty.Register("SelectedFilePath", typeof (string), typeof (FilePicker), new PropertyMetadata(default(string)));
  
  public string SelectedFilePath
  {
      get { return (string) this.TextBox_FilePath.GetValue(SelectedFilePathProperty); }
      set { this.TextBox_FilePath.SetValue(SelectedFilePathProperty, value); }
  }
  </code></pre>
  
  <p>which does work, but I've got no idea why?! Where did I specify I wanted the <code>text</code> property of the textbox?</p>
  
  <p><strong>What am I missing to simply proxy out that dependency property?</strong></p>
  
  <p><strong>EDIT:</strong>
  The solution with <code>AddOwner</code> doesn't work too, it throws an Excetion saying "binding can only be applied on a dependency property". Code:</p>
  
  <pre><code>public static readonly DependencyProperty SelectedFilePathProperty =
      TextBox.TextProperty.AddOwner(typeof(FilePicker));
  
  public string SelectedFilePath
  {
      get { return (string)this.TextBox_FilePath.GetValue(SelectedFilePathProperty); }
      set { this.TextBox_FilePath.SetValue(SelectedFilePathProperty, value); }
  }
  </code></pre>
  
  <p>What don't I understand?</p>
  
  <p><strong>EDIT2:</strong>
  For everybody else having issues understanding the answer, I've made <a href="https://stackoverflow.com/a/10997648/808723">a little graphic</a></p>