ورود

View Full Version : سوال: مشکل استفاده از پروپرتی از نوع کلاس برای رسم چارت



hercool
سه شنبه 27 آبان 1393, 14:17 عصر
سلام دوستان من می خوام از viewmodel اطلاعاتی را در چارت رسم کنم اما یه مشکل دارم
اونم این هست که نمی تونم از پروپرتی زیر مجموعه استفاده کنم در چارت کد رو میزارم ممنون میشم راهنماییم کنید
کامپوننت هم از تلریک استفاده می کنم

model
class People
{
private string fristname;
private string lastname;
private Int32 salary;
private ObservableCollection<Company> _company=new ObservableCollection<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 ObservableCollection<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; }
}
}
class 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 ObservableCollection<Company>() { new Company() { Cost = 1000, Name = "co1" } }, FristName = "masoud1", LastName = "fallah1", Salary = 150 });
data.Add(new People() { Company = new ObservableCollection<Company>() { new Company() { Cost = 2000, Name = "co2" } }, FristName = "masoud2", LastName = "fallah2", Salary = 250 });
data.Add(new People() { Company = new ObservableCollection<Company>() { new Company() { Cost = 3000, Name = "co3" } }, FristName = "masoud3", LastName = "fallah3", Salary = 350 });
data.Add(new People() { Company = new ObservableCollection<Company>() { new Company() { Cost = 4000, Name = "co4" } }, FristName = "masoud4", LastName = "fallah4", Salary = 450 });

Data = data;
}
}
اینم view
<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="FristName"
ValueBinding="Salary"
ItemsSource="{Binding ElementName=ChartDataSource1}">
</telerik:BarSeries>
</telerik:RadCartesianChart>

<telerik:RadCartesianChart x:Name="chart" Palette="Summer" Margin="0,25,0,0" Grid.Row="1">

<telerik:RadCartesianChart.HorizontalAxis>
<telerik:CategoricalAxis></telerik:CategoricalAxis>
</telerik:RadCartesianChart.HorizontalAxis>

<telerik:RadCartesianChart.VerticalAxis>
<telerik:LinearAxis HorizontalAlignment="Right"></telerik:LinearAxis>
</telerik:RadCartesianChart.VerticalAxis>

<telerik:RadCartesianChart.SeriesProvider >
<telerik:ChartSeriesProvider Source="{Binding Data}" x:Name="pro">
<telerik:ChartSeriesProvider.SeriesDescriptors>

<telerik:CategoricalSeriesDescriptor ItemsSourcePath="{Binding ElementName=ChartDataSource1}" ValuePath="Salary" CategoryPath="FristName">
<telerik:CategoricalSeriesDescriptor.Style>
<Style TargetType="telerik:BarSeries">
<Setter Property="CombineMode" Value="Cluster" />
</Style>
</telerik:CategoricalSeriesDescriptor.Style>
</telerik:CategoricalSeriesDescriptor>

<telerik:CategoricalSeriesDescriptor ItemsSourcePath="{Binding ElementName=ChartDataSource1}" ValuePath="Salary" CategoryPath="FristName" CollectionIndex="2">

</telerik:CategoricalSeriesDescriptor>

</telerik:ChartSeriesProvider.SeriesDescriptors>
</telerik:ChartSeriesProvider>

</telerik:RadCartesianChart.SeriesProvider>
</telerik:RadCartesianChart>
هر کاری کردم به Company نتونستم دسترسی پیدا کنم تا فیلد هاش رو بایندینگ کنم
ممنون میشم راهنماییم کنید

hercool
چهارشنبه 28 آبان 1393, 19:13 عصر
جالبش اینجاست که به بقیه کنترل های معمولی می تونم مقدار را پاس بدم اما در چارت کار نمیکنه ممنون میشم اگه کسی از دوستان با چارت تلریک اشنایی داره راهنمایی کنه