We have a Semantic Dev application that acquires data via RDF data sources at runtime; the app is data-driven so the declarative approach to XAML-centric programming is not ideal. Instead what I really need to do is bind the data at runtime and assign values to the Itemsoure (Datacontext), RingSeries and other attributes. I have played around with the API but have missed on several attempts. I just need to know what the coded-workflow is to bind to the control at runtime using the XamDoughtnut control API set.
Thanks!
Hello Tavi,
I attached a sample below that demonstrates how to bind the XamDoughnutChart in code behind. Let me know if you have any questions.
public partial class MainWindow : Window { public MainWindow() { var source = new HierarchalDataCollection(); InitializeComponent(); this.xamDoughnutChart.Series.Add(new RingSeries { LabelMemberPath = "Label", ValueMemberPath = "productionShare", LabelsPosition = LabelsPosition.BestFit, ItemsSource = source }); } } public class Category { public string Label { get; set; } public double productionShare { get; set; } } public class HierarchalDataCollection : List<Category> { public HierarchalDataCollection() { this.Add(new Category { Label = "Footwear", productionShare = 46 }); this.Add(new Category { Label = "Clothing", productionShare = 38 }); this.Add(new Category { Label = "Accessories", productionShare = 16 }); }
xamDoughnutChartCodeBehind.zip