title: Bind a Timespan to a Slider
body: <p>I have an interval in my program saved as a <code>TimeSpan</code>. I want to bind the value to a Slider to easy adjust the TimeSpan. My plan was something like this but it doesn't work (it does nothing at all):</p>
  
  <p><strong>EDIT: Changed some code based on the answers, but still i have the same problem</strong></p>
  
  <pre><code>public partial class MainWindow : Window, INotifyPropertyChanged
  {
  
      ...
  
  TimeSpan measure_gap = TimeSpan.FromSeconds(1); //init
  public double Measure_gap 
  {
      get
      {
          return measure_gap.TotalSeconds;
      }
      set
      {
          if (value != measure_gap.TotalSeconds)
          {
              measure_gap = TimeSpan.FromSeconds(value);
              OnPropertyChanged("Measure_gap");
          }
      }
  }
  
  public event PropertyChangedEventHandler PropertyChanged;
  
  public void OnPropertyChanged(string propertyName)
  {
      if (PropertyChanged != null)
          PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
  }
  </code></pre>
  
  <p>and here is my binding (i think the problem is here)</p>
  
  <pre><code>&lt;Slider HorizontalAlignment="Left" Height="25" Margin="38,202,0,0" 
   VerticalAlignment="Top" Width="217" Minimum="1" Maximum="10" SmallChange="1" 
   Value="{Binding ElementName=MainWindow, Path=Measure_gap, Mode=TwoWay}"/&gt;
  </code></pre>
  
  <p>So my question is, what am i doing wrong :-) thanks
  edit: this..BindingContext = this</p>