hi
i wanna binding property of subclass in main class to radcartesianchart with barseries
i very tired do this but dont work
my code
Model:
ViewModel:
view:code-behind
and view:
please help me :(
i wanna binding property of subclass in main class to radcartesianchart with barseries
i very tired do this but dont work
my code
Model:
class People { private string fristname; private string lastname; private Int32 salary; //private ObservableCollection<Company> _company=new ObservableCollection<Company>(); private Company _company = new Company(); public string FristName { get { return this.fristname; } set { this.fristname = value; } } public string LastName { get { return this.lastname; } set { this.lastname = value; } } public Int32 Salary { get { return this.salary; } set { this.salary = value; } } public Company Company { get { return this._company; } set { this._company = value; } } }public class Company { private string name; private Int32 cost; public string Name { get { return this.name; } set { this.name = value; } } public Int32 Cost { get { return this.cost; } set { this.cost = value; } } }ViewModel:
class peopleViewModel : DependencyObject { public static readonly DependencyProperty DataProperty = DependencyProperty.Register("Data", typeof(ObservableCollection<People>), typeof(peopleViewModel), new PropertyMetadata(null)); public ObservableCollection<People> Data { get { return (ObservableCollection<People>)this.GetValue(DataProperty); } set { this.SetValue(DataProperty, value); } } public peopleViewModel() { var data = new ObservableCollection<People>(); data.Add(new People() { Company = new Company() { Cost = 1000, Name = "co1" } , FristName = "masoud1", LastName = "fallah1", Salary = 150 }); data.Add(new People() { Company = new Company() { Cost = 2000, Name = "co2" } , FristName = "masoud2", LastName = "fallah2", Salary = 250 }); data.Add(new People() { Company = new Company() { Cost = 3000, Name = "co3" } , FristName = "masoud3", LastName = "fallah3", Salary = 350 }); data.Add(new People() { Company = new Company() { Cost = 4000, Name = "co4" } , FristName = "masoud4", LastName = "fallah4", Salary = 450 }); Data = data; } }public partial class PeopleView : Page { public PeopleView() { InitializeComponent(); peopleViewModel Data = new peopleViewModel(); this.DataContext = Data; // pro.Source = Data; } }<telerik:ChartDataSource x:Name="ChartDataSource1" ItemsSource="{Binding Data}" Grid.RowSpan="2" /><telerik:RadCartesianChart x:Name="RadChart1" Margin="0,0,0,10"> <telerik:RadCartesianChart.HorizontalAxis> <telerik:DateTimeCategoricalAxis /> </telerik:RadCartesianChart.HorizontalAxis> <telerik:RadCartesianChart.VerticalAxis> <telerik:LinearAxis/> </telerik:RadCartesianChart.VerticalAxis> <telerik:BarSeries x:Name="bar" ShowLabels="True" CategoryBinding="{Binding Path=Company.Cost}" ValueBinding="Salary" ItemsSource="{Binding ElementName=ChartDataSource1}" > </telerik:BarSeries></telerik:RadCartesianChart>