我尝试实现 WinRT XAML 工具包数据可视化我有一个分组的数据列表
ObservableCollection<Notes> items = await App.DataModel.GetNotes();
var groupedData = (from data in items
group data by data.Title into g
orderby g.Key
select new Group<string, Notes>
{
Key = g.Key.ToString(),
Items = g.ToList()
}).ToList();
List<GroupedDataType> groupedList2 = new List<GroupedDataType>();
foreach (var item in groupedData)
{
int results = 0;
foreach (var rslt in item.Items)
{
results += rslt.Result;
}
groupedList2.Add(new GroupedDataType(results, item.Items[0].Title));
}
PieChart.ItemsSource= groupedList2;
班上:
public GroupedDataType(int totalresult, string type)
{
TotalResult = totalresult;
Type = type;
}
public int TotalResult { get; set; }
public string Type { get; set; }
XAML 代码:
<Charting:PieSeries x:Name="PieChart"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
IndependentValueBinding="{Binding Type}"
DependentValueBinding="{Binding TotalResult}">
</Charting:PieSeries>
但它没有显示任何图表,请帮助我知道我的代码是否有问题,
谢谢你。