【问题标题】:silverlight selectively bind properties to piechart?silverlight 选择性地将属性绑定到饼图?
【发布时间】:2013-04-03 01:52:04
【问题描述】:

如果我有一个包含许多属性的自定义类,如何将其中的一些属性绑定到 silverlight 工具包饼图?例如:

public class Expense
{
    public double food;
    public string food_description;
    public double rent;
    public string rent_description;
    public double renterInsurance;
    public string renterInsurance_description;

    ...
}

如何将其绑定到饼图,以便在饼图中显示“food”和“renterInsurance”(但不是“rent”),并在图例中显示它们的相应描述?

这源于我早些时候发布的一个未回答的问题。有人提出了一个建议,我认为如果调整数据结构可能会有所帮助。但这取决于是否会回答这个问题。

这是我最初的问题。如果您有一个好的答案,我将不胜感激: https://stackoverflow.com/questions/15704622/silverlight-can-i-do-this-through-data-binding

【问题讨论】:

    标签: c# silverlight data-binding charts pie-chart


    【解决方案1】:

    这样做,

     PieSeries pie1 = new PieSeries();
     pie1.IndependentValueBinding = new Binding("food");
                                    pie1.DependentValueBinding=new Binding("renterInsurance");
                                    pie1.ItemsSource = tempData;
                                    chart1.Series.Add(pie1);
    
     pie1.ItemsSource = List<YourClass>;
    

    【讨论】:

    • 感谢您的回复 Sajeetharan。但是,“food”和“renterInsurance”都需要绑定为 DependentValue,因为它们是构成饼图的两个值。我还需要将两个“_description”绑定到同一个饼图系列,所以描述会显示在图例中。
    猜你喜欢
    • 2012-01-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-15
    • 2016-05-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多