Silverlight:如何将加载操作的结果绑定到包含很少空值的LineSeries图表
我已将我的图表绑定到加载操作的结果。加载操作返回的结果返回复杂类型,其中某些对象属性的值为 null。
所以我的银光应用程序出现错误。
我的 XAML 代码如下:
<Grid x:Name="LayoutRoot">
<toolkit:Chart Name="historicalTotalChart" Title="Chart Title">
<toolkit:LineSeries >
</toolkit:LineSeries>
</toolkit:Chart>
</Grid>
我的 CS 文件中的代码如下:
LoadOperation<GetHistoricalTotalReport_Result> hisTotalsLoadOp =
context.Load(context.GetHistoricalToalReportQuery(tableName, sD, startDate, endDate));
LineSeries line = new LineSeries();
line.ItemsSource = hisTotalsLoadOp.Entities;
//line.DependentValuePath ="rep_date";
//line.IndependentValuePath = "expr1";
line.DependentValueBinding = new Binding("[rep_date]");
line.IndependentValueBinding = new Binding("[expr1]");
line.Title = "Historical Totals";
historicalTotalChart.Series.Add(line);
谁能说一下我该如何克服这个错误?
rep_date、expr1 是我的复杂类型 GetHistoricalTotalReport_Result 中的属性。我是否正确绑定到属性?
非常感谢任何帮助。
谢谢
I have bound a my chart to a result of load operation. The result returned by the load operation returns complex type with values for some of the object's properties is null.
So I am getting an error in my silver light application.
The code of my XAML is as follows:
<Grid x:Name="LayoutRoot">
<toolkit:Chart Name="historicalTotalChart" Title="Chart Title">
<toolkit:LineSeries >
</toolkit:LineSeries>
</toolkit:Chart>
</Grid>
Code of in my CS file is as follows:
LoadOperation<GetHistoricalTotalReport_Result> hisTotalsLoadOp =
context.Load(context.GetHistoricalToalReportQuery(tableName, sD, startDate, endDate));
LineSeries line = new LineSeries();
line.ItemsSource = hisTotalsLoadOp.Entities;
//line.DependentValuePath ="rep_date";
//line.IndependentValuePath = "expr1";
line.DependentValueBinding = new Binding("[rep_date]");
line.IndependentValueBinding = new Binding("[expr1]");
line.Title = "Historical Totals";
historicalTotalChart.Series.Add(line);
Can any one say how can I over come this error?
rep_date, expr1 are the properties with in my complex type GetHistoricalTotalReport_Result. I am I binding to the properties correctly?
Any help much appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的应用程序中可能存在 3 个问题:
Dependent
/IndependentValuePath
,您不应该评论它们,它们是完全正确的。DependentValuePath
属性必须是数字数据类型,因为它位于 Y 轴上。在您的示例中,rep_date
属性可以是double
类型。IndependentValuePath
位于 X 轴上,可以是任何类型,但值不能包含 null。真的,我不知道空值可以在X轴上显示在哪里,这没有意义。这是正确代码的示例,可以正常工作:
下一个代码将不起作用:
但您可以在显示实体之前过滤它们:
There are 3 possible issues in your application:
Dependent
/IndependentValuePath
, you shouldn't comment them, they are completely correct.DependentValuePath
property must be of a numerical data type, because it is situated on the Y-axis. In your example therep_date
property could be of thedouble
type.IndependentValuePath
is situated on the X-axis and could be of any type but the values can't contain nulls. Really, I have no idea where a null value can be displayed on the X-axis, it doesn't make sense.Here is the example of the correct code which works fine:
The next code will not work:
But you can filter your entities before displaying them: