Bind to a List
(or any other collection) even if it contains only one item.
public List<CountClass> Q1List {get{...}}
And your binding:
<chartView:BarSeries ItemsSource="{Binding Q1List}" .../>
Question
I am attempting a telerik barseries control to plot some data. This is only my sample and I cant get it to working. I followed the examples available and read about data binding and still cant get to why this is not working for me.
Here is what I have done.
Define a basic class:
public class CountClass
{
private int count;
private string name;
public string Name
{
get
{
return name
}
set
{
name= value;
}
}
public int Count
{
get
{
return count;
}
set
{
count= value;
}
}
public CountClass(string tempname, int value)
{
name = tempname;
count = value;
}
}
public class QClass : Telerik.Windows.Controls.ViewModelBase
{
private CountClass q1;
private CountClass q2;
public QClass()
{
}
public CountClass Q1
{
get
{
q1 = new CountClass ("Count1", 100);
return q1;
}
}
public CountClass Q2
{
get
{
q2 = new CountClass ("Count2", 200);
return q2;
}
}
}
public partial class MainPage : UserControl
this.DataContext = new SilverlightApplication2.QClass();
And xaml:
<chartView:BarSeries ItemsSource="{Binding Q1}"
FontFamily="Segoe UI"
FontSize="10"/>
What am I doing wrong?
La solution
Bind to a List
(or any other collection) even if it contains only one item.
public List<CountClass> Q1List {get{...}}
And your binding:
<chartView:BarSeries ItemsSource="{Binding Q1List}" .../>