Pre loader

ToValidDateTimeConverter is not in Abt.Controls.SciChart.Common error

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

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.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies