I am trying to bind a DataClick event of a Carteian Chart LiveChart element using the MVVM template.
I have my own Charts.xml like this:
<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>
This is my ICommand ChartDataClick on my ViewModel:
public ICommand ChartDataClick {
get
{
if(_dataClickCommand == null)
{
_dataClickCommand = new DelegateCommand(
() =>
{
MessageBox.Show("Data Clicked!");
}
);
}
return _dataClickCommand;
}
}
If I switch, for example, "DataClick" for "MouseEnter", I run my command.
So, I guess the problem is that DataClick is a custom event.
Does anyone know a workaround for this? I really tried everything I could find on Google that could help, but nothing so far ...
LiveCharts Events: Event Documentation