title: Binding class properties to UserControl in MVVM
body: <p>I have a class that contains a string property called Text.</p>
  
  <pre><code>   public class Time
      {
          private string _text;
          public string Text
          {
              get { return _text; } 
              set { _text = value; }
          }
      }
  </code></pre>
  
  <p>I also have a custom UserControl which contains this class.</p>
  
  <pre><code>public partial class MyUserControl : UserControl, INotifyPropertyChanged
  {
  &lt;...&gt;
      private Time _myTime;
      public Time MyTime
      {
              get { return _myTime; }
              set { _myTime= value; NotifyPropertyChanged(); } 
      }
  }
  </code></pre>
  
  <p>From my ViewModel, I want to create the above UserControl and assign to it a Time class and all of its properties:</p>
  
  <pre><code>void SomeMethod()
  {
      Time TestTime = new Time();
      TestTime.Text = "Hello world";
  
      MyUserControl control = new MyUserControl();
      control.MyTime = TestTime;
  
      controlViewer = new System.Collections.ObjectModel.ObservableCollection&lt;Control&gt;();
      controlViewer.Add(control);
          // on my main window, I have an ItemsControl with 
          // ItemsSource="{Binding controlViewer}".
  }
  </code></pre>
  
  <p>The XAML for the UserControl contains this TextBox:</p>
  
  <pre><code>&lt;TextBox Text="{Binding MyTime.Text}"/&gt;
  </code></pre>
  
  <p>I am then able to call the control.MyTime.Text property programmatically and get the "Hello world" value just fine -- but I can't get it to show on the newly created MyUserControl's textbox.</p>