Change Maximum to "86400".
That is 24 hours in seconds.
This will give you a granularity of 1 second.
Please have a look at the example below:
The conversion from seconds to e.g. 12:22:45
will be done by a value converter.
TimeConverter.cs
using System;
using System.Windows.Data;
namespace WpfApplicationSliderTest
{
class TimeConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string timeString = string.Empty;
int seconds = System.Convert.ToInt32((double)value);
TimeSpan ts = new TimeSpan(0, 0, seconds);
timeString = ts.ToString(@"hh\:mm\:ss");
return timeString;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
MainWindow.xaml:
<Window x:Class="WpfApplicationSliderTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplicationSliderTest"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<local:TimeConverter x:Key="tc"></local:TimeConverter>
</Window.Resources>
<Grid>
<StackPanel Orientation="Vertical">
<Slider x:Name="slider" Minimum="0" Maximum="86400" SmallChange="1" LargeChange="1" TickFrequency="1" IsSnapToTickEnabled="True" Margin="10"></Slider>
<TextBlock Text="{Binding ElementName=slider,Path=Value,Converter={StaticResource tc}}"></TextBlock>
</StackPanel>
</Grid>
</Window>
Dragging the slider does not show the real granularity.
The steps seem to be bigger.
I added SmallChange="1". When you use the arrow up/down keys on your keyboard
you see each key press is changing the value by 1.
I also added LargeChange="1". When you click left or right of the slider button
the value is also increased/decreased by 1.