-3

可以使用标准 Silverlight 控件来完成吗?

在此处输入图像描述

谢谢!

4

1 回答 1

0

OK完成!

在此处输入图像描述

我可以找到 XAML 来做到这一点。

 <toolkit:Chart Height="400" Width="600" Title="Cumulative Age Dispersions" >
                <toolkit:ColumnSeries  ItemsSource="{Binding MaleSerie}" IndependentValueBinding="{Binding ItemName}"
                    DependentValueBinding="{Binding Count}"  
                    HorizontalAlignment="Left" Height="304" VerticalAlignment="Top" Width="266">
                </toolkit:ColumnSeries >

                <toolkit:ColumnSeries  ItemsSource="{Binding FemaleSerie}" IndependentValueBinding="{Binding ItemName}"
                    DependentValueBinding="{Binding Count}"  
                    HorizontalAlignment="Left" Height="304" VerticalAlignment="Top" Width="266">
                </toolkit:ColumnSeries >


            </toolkit:Chart>

和 C#

   public class Sex
    {
        public string ItemName { set; get; }

        public int Count { set; get; }
    }


  public class MergedData
    {     
        public List<Sex> MaleSerie { set; get; }

        public List<Sex> FemaleSerie { set; get; }
    }

  void UC_Loaded(object sender, RoutedEventArgs e)
        {
            MergedData md = new MergedData();
  List<Sex> maleSerie = new List<Sex>();
            maleSerie.Add(new Sex() { ItemName = "Car", Count = 10});
            maleSerie.Add(new Sex() { ItemName = "Water", Count = 20 });
            maleSerie.Add(new Sex() { ItemName = "Sport", Count = 30 });

            md.MaleSerie = maleSerie;

            List<Sex> femaleSerie = new List<Sex>();
            femaleSerie.Add(new Sex() { ItemName = "Car", Count = 40 });
            femaleSerie.Add(new Sex() { ItemName = "Water", Count = 34 });
            femaleSerie.Add(new Sex() { ItemName = "Sport", Count = 87 });

            md.FemaleSerie = femaleSerie;


            this.DataContext = md;
}

PS这里有一些有趣的图表生成器http://blogs.msdn.com/b/delay/archive/2008/12/10/great-silverlight-charts-are-still-just-a-click-away-chartbuilder- sample-and-source-code-updated-for-charting-s-december-08-release.aspx 它很旧,但您可以轻松地将其转换为 Visual Studio 2012。:)

于 2013-03-18T14:51:04.170 回答