win 8 商店应用程序:
目前效果如下:
我想把它的红蓝色块改成别的颜色,请问怎么改,如下是代码:
CS代码:
/// <summary>
/// 饼状图
/// </summary>
private void UpdateCharts()
{
List<NameValueItem> items = new List<NameValueItem>();
NameValueItem nv = new NameValueItem();
nv.Value = Convert.ToInt32(20);
nv.Name = nv.Value.ToString() + "% 及格比例";
NameValueItem nv1 = new NameValueItem();
nv1.Value = Convert.ToInt32(100 - Convert.ToInt32(20));
nv1.Name = nv1.Value.ToString() + "% 不及格比例";
items.Add(nv);
items.Add(nv1);
((PieSeries)this.PieChart.Series[0]).ItemsSource = items;
}
public class NameValueItem
{
public string Name { get; set; }
public int Value { get; set; }
}
XAML代码:
<Charting:Chart
Grid.Row="1" Grid.Column="0"
HorizontalAlignment="Left"
Width="500"
x:Name="PieChart"
Title="" Foreground="Black" FontSize="12">
<Charting:Chart.Series>
<Series:PieSeries
Title="Population"
ItemsSource="{Binding Items}"
IndependentValueBinding="{Binding Name}"
DependentValueBinding="{Binding Value}"
IsSelectionEnabled="True"/>
</Charting:Chart.Series>
</Charting:Chart>
------解决方案--------------------
看半天了就是不会