title: How can I access a view property from my ViewModel?
body: <p>I have a ViewModel whose properties are bounded to from the View (XAML file).
  I also have a property "StaticText" in the code behind file.</p>
  
  <p>how can I access the property "StaticText" from inside the ViewModel ?</p>
  
  <p>as suggested by Cameron, i've created a dependency property in my View :</p>
  
  <pre><code>    String textToTest="I am just testing .";
  
       public string TextToTest
       {
           get { return (string)this.GetValue(TextToTestProperty); }
           set { this.SetValue(TextToTestProperty, value); }
       }
       public static readonly DependencyProperty TextToTestProperty =
           DependencyProperty.Register("TextToTest", typeof(string),
           typeof(MainWindow), new PropertyMetadata(false));
  </code></pre>
  
  <p>and I've added this to the constructor :</p>
  
  <pre><code>         Binding aBinding = new Binding();
           aBinding.Path = new PropertyPath("TextToTest");
           aBinding.Source = viewModel;
           aBinding.Mode = BindingMode.TwoWay;
           this.SetBinding(TextToTestProperty, aBinding);
  </code></pre>
  
  <p>but I get an exception when I run the code.</p>