title: How can i make a dynamic slider in wpf?
body: <p>I'm working on a hobby project. I'd like to create a simple media player application and i have a problem with one of my sliders. I'd like to make it dynamic so it's maximum value would be the same as the actual audio file's length that's opened in my application.</p>
  
  <p>So if first.wav file's length is 56 seconds then my slider's maximum value would be 56.</p>
  
  <p>I have the following property in C#:</p>
  
  <pre><code>    private TimeSpan Duration { get; set; }
  </code></pre>
  
  <p>This property is responsible for storing the length of my actual audio file. It gets initialized after i browse the audio file. It stores the correct number so there's no problem with it. My problem is that i don't know how to bind it to the slider correctly.</p>
  
  <p>This is my slider:</p>
  
  <pre><code>    Slider Grid.Column="0" x:Name="SliderForCurrentTime" Minimum="1" Maximum="300" TickFrequency="1" IsMoveToPointEnabled="True" ValueChanged="SliderForCurrentTime_ValueChanged"/&gt;
  </code></pre>
  
  <p>When i play the audio file i increment the slider with every tick of a DispatcherTimer so the slider always "points" at the position of my media player. My tick frequency is 1 and i'd like it to tick as many times as the maximum value of the slider so i could go back and forth in the audio file by clicking on the slider.</p>
  
  <p>It works great with a fixed maximum value but that's not an elegant solution i guess so i'd like to make it dynamic. Any ideas?</p>