title: How to Bind to a methods in Windows Forms
body: <p>I am trying to bind <code>monthCalendar</code> date to <code>MyDate</code> property and avoid circular invocation but monthCalendar doesn't have <code>get;set;</code> properties for current selected date. It has only method <code>SetDate(DateTime date);</code> for setting new date and events <code>monthCalendar1_DateChanged</code>, <code>monthCalendar1_DateSelected</code> for returning current selected date. How to bind them to <code>MyDate</code> property? In WPF method is available as a resource so you can bind to its results. How to achieve that in <code>System.Windows.Forms</code>?</p>
  
  <pre><code>    private static readonly object _dateLock = new object();
  
      private DateTime myDate = DateTime.Now;
  
      public DateTime MyDate
      {
          get
          {
              lock (_dateLock)
              {         
                  //updating control
                  return myDate;                    
              }
          }
  
          set
          {
              lock (_dateLock)
              {         
                  //getting date from control
                  myDate = value;   
                  SetDate(new DateTime(myDate.Ticks));
              }
          }
      }
  
      //Fired when date changed
      private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)
      {
          //update source
          lock (_dateLock)
          {         
              MyDate = new DateTime(e.Start.Ticks);   
          }         
      }
  
  
      private void monthCalendar1_DateSelected(object sender, DateRangeEventArgs e)
      {
          //Check if bottom region with current date clicked
          if (IsCurrentDateClikced())
          {             
              //update source    
              lock (_dateLock)
              {              
                 MyDate = new DateTime(DateTime.Now.Ticks);   ;
              }
          }       
      }
  </code></pre>