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

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.