title: How do I make a C# user control property data bindable?
body: <p>I have a MVVM Windows Phone 8 app.  The XAML page has a <em>user control</em> that I created that needs to be notified when a change takes place in the <strong>View Model</strong>.  To facilitate this, I created an <em>int</em> property in the <em>user control</em> to be bound to a property in the <strong>View Model</strong>, so the <em>user control</em> property's <em>setter</em> method would be triggered when the property it was bound to in the <strong>View Model</strong> changed.</p>
  
  <p>Using the code below, the <em>user control's</em> <strong>VideosShownCount</strong> property does show up in the <em>Property List</em> at design-time but when I click on the binding mini-button, the <em>Create Data Binding</em> option is <em>greyed out</em> in the pop-up menu.</p>
  
  <p>So I have one or two questions, depending on what is the root problem:</p>
  
  <p>1) How do I make a property in a <strong>View Model</strong> available as a Data Binding source?</p>
  
  <p>2) How do I format a <em>user control</em> property so the IDE allows it to be data bound to a <strong>View Model</strong> property?</p>
  
  <pre><code>    private int _videosShownCount = 0;
  
      public int VideosShownCount 
      { 
          get
          {
              return this._videosShownCount;
          }
          set
          {
              this._videosShownCount = value;
          }
      }
  
      public static readonly DependencyProperty VideoShownCountProperty =
          DependencyProperty.Register("VideosShownCount", typeof(int), typeof(MyUserControl), 
          new PropertyMetadata(0, new PropertyChangedCallback(VideoShownCountPropertyChanged))); 
  
      static void VideoShownCountPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
      {
          MyUserControl MyUserUserControl = (MyUserControl)sender;
  
          // Don't care about the value, just want the notification.
          // int val = (int)e.NewValue;
  
          // Do work now that we've been notified of a change.
          MyUserUserControl.DoWork();
      }
  </code></pre>