Pre loader

Using Abstract DataSeries as parent in INotifyPropertyChanged object

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

Hi,

I’m attempting to attach a generic/abstract DataSeries to an INotifyPropertyChanged object. However, the TX, TY generics seem to block me from using it as expected. Can anyone help me out?

internal class DataSeriesAbstract : INotifyPropertyChanged
{
    public string dataName;
    public double lastAppendedTimestamp = 0.0f;

    public List<AbstractChartViewModel> subscribers;

    // gives an error that TX and TY cannot be found
    public DataSeries<TX, TY> realData;
    public DataSeries<TX, TY> Data
    {
        get { return realData; }
        set
        {
            realData = value;
            OnPropertyChanged(dataName);
        }
    }
...
}

Thank you

Version
5
  • You must to post comments
0
0

Hi Jan

According to c# language spec, you have to do this:

// Specify the TX,Ty here making the class generic 
internal class DataSeriesAbstract<TX,TY> : INotifyPropertyChanged where TX:IComparable where TY:IComparable
{
    public string dataName;
    public double lastAppendedTimestamp = 0.0f;
 
    public List<AbstractChartViewModel> subscribers;
 
    public DataSeries<TX, TY> realData;
    public DataSeries<TX, TY> Data
    {
        get { return realData; }
        set
        {
            realData = value;
            OnPropertyChanged(dataName);
        }
    }
...
}

or this

internal class DataSeriesAbstract : INotifyPropertyChanged
{
    public string dataName;
    public double lastAppendedTimestamp = 0.0f;
 
    public List<AbstractChartViewModel> subscribers;
 
    // Specify the type here 
    public DataSeries<double, double> realData;
    public DataSeries<double, double> Data
    {
        get { return realData; }
        set
        {
            realData = value;
            OnPropertyChanged(dataName);
        }
    }
...
}

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