I am using a trial version of SciChart and was referring to WPF example of modifying the date time axis. I am getting an error in the below line that the class ToValidDateTimeConverter is not included in Common namespace
((ToValidDateTimeConverter)grid.Resources[“ToValidDateTimeConverter”]).XVisibleRange = (DateRange)xAxis.VisibleRange;
- Harish Thankappan asked 8 years ago
- You must login to post comments
Hi there,
ToVaildDateTimeConverter is part of the WPF Examples Codebase, which is found on disk when you install the SciChart Trial.
We include a number of classes/helper methods in the examples to demonstrate usage of SciChart. These are not included in SciChart itself but you may use them by taking them from the examples code.
For your convenience, the source for ToValidDateTimeConverter is included below.
public class ToValidDateTimeConverter : IValueConverter
{
public DateRange XVisibleRange { get; set; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (XVisibleRange == null || value == null) return value;
return ValidateDate(value, parameter);
}
private object ValidateDate(object value, object parameter)
{
var newDate = (DateTime) value;
switch (parameter.ToString())
{
case "Max":
if (XVisibleRange.Min >= newDate)
{
newDate = XVisibleRange.Max;
}
break;
case "Min":
if (XVisibleRange.Max <= newDate)
{
newDate = XVisibleRange.Min;
}
break;
}
return newDate;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (XVisibleRange == null || value == null) return value;
return ValidateDate(value, parameter);
}
}
Best regards,
Andrew
- Andrei Barsa answered 8 years ago
- You must login to post comments
Please login first to submit.