xamarin - 如何将图表绑定到列表在 Xamarin.Forms 中的 XamDataChart 中?
问题描述
我有一个清单如下
public List<MonthlyData> MonthlyList;
public class MonthlyData
{
public int Count;
public string Month;
}
列表 MonthlyList 填充了 12 个项目,其中包含每个月的计数。
我试图在 XamDataChart 中显示列表,但它只显示一个空白页。
XAML 代码:
<ig:XamDataChart x:Name="Chart" >
<ig:XamDataChart.Axes>
<ig:CategoryXAxis x:Name="XAxis" ItemsSource="{Binding MonthlyList}" Label="{}{Month}" />
<ig:NumericYAxis x:Name="YAxis" />
</ig:XamDataChart.Axes>
<ig:XamDataChart.Series>
<ig:StackedColumnSeries x:Name="series" ItemsSource="{Binding MonthlyList}" Title="Data" XAxis="{x:Reference XAxis}" YAxis="{x:Reference YAxis}">
<ig:StackedColumnSeries.Series>
<ig:StackedFragmentSeries ValueMemberPath="Count" />
</ig:StackedColumnSeries.Series>
</ig:StackedColumnSeries>
</ig:XamDataChart.Series>
</ig:XamDataChart>
解决方案
从文件:
数据绑定允许链接两个对象的属性,以便一个对象的更改导致另一个对象的更改。
所以你只能绑定到公共属性而不是变量。
解决方案:
public List<MonthlyData> MonthlyList { get; set; }
推荐阅读
- oracle - Oracle Reports Builder 条码字体消失
- qt - QtQuick 2.12 中的垂直滑动
- c - zsh shell 中的百分号从何而来?
- javascript - Angular 上的缓存破坏
- docker - 如何使用自定义配置通过 docker 运行 hyperledger besu 节点?
- python - 如何绘制用于分组子图的括号
- javascript - 在 JS 中监听基础切换器
- docker - 在 windows 10 pro 上安装 Docker 失败:需要 Windows 10 Pro/Enterprise/Home (18363+)
- tensorflow - 构建用于参数预测的自动编码器网络
- javascript - 如果我使用 cypress-cucumber,是否必须为每个功能文件创建步骤定义文件夹?