Skip to content

Instantly share code, notes, and snippets.

@naotaco
Last active October 7, 2015 15:39
Show Gist options
  • Save naotaco/007e752fd01493b521da to your computer and use it in GitHub Desktop.
Save naotaco/007e752fd01493b521da to your computer and use it in GitHub Desktop.
{
// somewhere
Slider.ThumbToolTipValueConverter = new SliderValueConverter() { Labels = new List<string>(){"a", "b", "c"} };
}
public class SliderValueConverter : IValueConverter
{
public List<string> Labels { get; set; }
public object Convert(object value, Type targetType, object parameter, string language)
{
var selected = (int)Math.Round((double)value);
if (Labels == null || selected >= Labels.Count) { return value.ToString(); }
return Labels[selected];
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment