问题
I have a time chart that shows measurements of temperature over time.
I would like to be able to display either absolute time or relative time, which is spent time from a defined starting point (so a TimeSpan).
The data points are DateTime in absolute and temperature, I would like to avoid rewriting all the time series with relative value each time the user change.
So far my goal was to create a converter for formatting the X-Axis labels with the time and handle the logic in there, passing the starting point as a parameter and whether it should be displayed as absolute or relative values.
The Converter handling care to calculate relative values.
So Far my xamls looks like:
<telerik:RadCartesianChart.HorizontalAxis>
<telerik:DateTimeCategoricalAxis>
<telerik:DateTimeCategoricalAxis.LabelTemplate>
<DataTemplate>
<TextBlock Text="{Binding Converter={StaticResource TimeChartConverter},
ConverterParameter=<<<????>>>}" />
</DataTemplate>
</telerik:DateTimeCategoricalAxis.LabelTemplate>
</telerik:DateTimeCategoricalAxis>
</telerik:RadCartesianChart.HorizontalAxis>
Which works, the issue is how to pass the starting time to the converter, it seems the parameter is not bindable, is there any tricks to achieve this?
来源:https://stackoverflow.com/questions/65957651/wpf-time-chart-with-absolute-or-relative-time-option