【发布时间】:2016-10-11 12:08:32
【问题描述】:
我正在尝试使用 MVVM 模式绑定 LiveChart 笛卡尔图表元素的“DataClick”事件。
我的 Charts.xml 是这样的:
<ContentControl Grid.Row="0">
<lvc:CartesianChart x:Name="ContrastChart" Series="{Binding ContrastSeriesCollection}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="DataClick">
<i:InvokeCommandAction Command="{Binding ChartDataClick}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</lvc:CartesianChart>
</ContentControl>
这是我的 ViewModel 上的 ICommand ChartDataClick:
public ICommand ChartDataClick {
get
{
if(_dataClickCommand == null)
{
_dataClickCommand = new DelegateCommand(
() =>
{
MessageBox.Show("Data Clicked!");
}
);
}
return _dataClickCommand;
}
}
如果我将例如“DataClick”切换为“MouseEnter”,我的命令就会被触发。
所以我假设问题在于 DataClick 是一个自定义事件。
有人知道解决方法吗? 我真的尝试了所有可以在 Google 上找到的可以提供帮助的方法,但目前还没有...
LiveCharts 事件:Events Documentation
【问题讨论】:
标签: c# wpf mvvm prism livecharts