SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy

We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

0
0

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;

  • You must to post comments
0
0

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

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.