I want to show a Line Series using WinRT XAML toolkit for Windows Phone 8.1 I have the following code but nothing appears on the screen:(I am using MVVM Light for implementing MVVM) Website.xaml
<Grid Grid.Row="0" Background="Black" Margin="20,20,10,10">
<charting:LineSeries x:Name="LineSeries" Height="250" Width="320" ItemsSource={Binding DataPoints} IndependentValueBinding="{Binding X}" DependentValueBinding="{Binding Y}">
</charting:LineSeries>
</Grid>
In the corresponding view model I have
public class WebsiteViewModel:ViewModelBase
{
private List<DataPoint> _datapoints;
public List<DataPoint> DataPoints
{
get
{
return _datapoints;
}
set
{
if(_datapoints!=value)
{
_datapoints=value;
RaisePropertyChanged("DataPoints");
}
}
}
public WebsiteViewModel()
{
if(IsInDesignMode)
{
DataPoint p1=new DataPoint(){X="ABC",Y=21.23};
DataPoint p2=new DataPoint(){X="XYZ",Y=34.56};
DataPoints=new List<DataPoint>();
DataPoints.Add(p1);
DataPoints.Add(p2);
}
}
}
And DataPoint class is defined below:
public class DataPoint:ObservableObject
{
private string _x;
public string X
{
get
{
return _x;
}
set
{
if(_x!=value)
{
_x = value;
RaisePropertyChanged("X");
}
}
}
private double _y;
public double Y
{
get
{
return _y;
}
set
{
if(_y!=value)
{
_y = value;
RaisePropertyChanged("Y");
}
}
}
}
But I can't see any data at design time. I have set the DataContext in XAML using the ViewModelLocator property. Is there something wrong with my code? Does WinRTXAML toolkit actually work with WP 8.1? If not, can anyone point me to any other open-source chart library for WP 8.1? I've looked up Sparrow, but it is only WP8 compatible.