WPF MVVM MahApps range slider with dates in tooltip
在WPF MVVM应用程序中使用以下https://mahapps.com/docs/controls/rangeslider。当前,工具提示显示数值,而我希望显示日期。
我在以下答案WPF滑块和日期中找到了转换器
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | public class HourToDateConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { object result = DependencyProperty.UnsetValue; if (value is double) result = DateTime.Now.Date.AddHours((double)value); return result; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } |
我已经成功获得了
这可能吗?预先感谢。
尝试将
1 2 3 4 5 6 7 8 9 10 11 12 | <Grid> <Grid.Resources> <local:HourToDateConverter x:Key="HourToDateConverter" /> </Grid.Resources> <Controls:RangeSlider x:Name="xxx" Minimum="10" Maximum="100" AutoToolTipPlacement="TopLeft" AutoToolTipPrecision="2" MoveWholeRange="True" IsSnapToTickEnabled="True" IsMoveToPointEnabled="True" ExtendedMode="True" AutoToolTipTextConverter="{StaticResource HourToDateConverter}"> </Controls:RangeSlider> </Grid> |