我需要将隔离存储中某些特定文件的名称和创建日期与 amq:SerialChart 的数据源绑定。(windows phone 7.8)我尝试为此制作一个视图模型。
public class MainViewModel
{
public MainViewModel()
{
var appStorage = IsolatedStorageFile.GetUserStoreForApplication();
var items = new List<ChartItemViewModel>();
string[] fileName = appStorage.GetFileNames("issue*");
foreach( string file in fileName)
{
items.Add(new ChartItemViewModel { Month =file, Value=appStorage.GetCreationTime(file).ToString()});
}
var chart = new ChartViewModel { Items = items };
this.Charts = Enumerable.Repeat(0, 5).Select(_ => chart).ToList();
}
public List<ChartViewModel> Charts { get; set; }
}
}
但是当我运行它时我遇到了异常。相同的xaml代码是
<controls:PivotItem Header="Line">
<amq:SerialChart Style="{StaticResource chartStyle}"
DataSource="{Binding Charts[0].Items}"
CategoryValueMemberPath="Month">
<amq:SerialChart.Graphs>
<amq:LineGraph ValueMemberPath="Value" Title="Test Chart" />
</amq:SerialChart.Graphs>
</amq:SerialChart>
</controls:PivotItem>