Hello,
I can databind linechart to custom IEnumerable collection, this is done with ObjectDataProvider in XAML like this:
In <Window.Resources>:
<ObjectDataProvider x:Key="PatientData" ObjectType="{x:Type local:PatientDataReader}" MethodName="GetData"/>
In <XamChart>:
StrokeThickness="3"
DataSource="{Binding Source={StaticResource PatientData}}"
DataMapping="Label=Name; Value=Age">
</igCA:Series>
However, now need to change the binding in runtime, it requires code in C# code-behind file.
How is this done? Should I use DataContext or what?
-pom-
Ha! Sometimes one just comes up with the solution right after the question is asked.
This is the solution in the code behind:
provider.MethodName = "GetData2";
This will dynamically change the method on the bound object to another! Not actually XamChart feature but a general WPF feature.
Hi,
To change data source in runtime DataSource and DataMapping properties have to be set. The DataSource property just needs a reference to your collection in runtime:
private void Button1_Click(object sender, RoutedEventArgs e)
{ this.xamChart1.RefreshEnabled = false; this.xamChart1.DataSource = myCollection; this.xamChart1.DataMapping=” Label=Name; Value=Age”; this.xamChart1.RefreshEnabled = true;
}
Thanks,GoranS