Retrieve selected item from columnseries using Blend Behaviors on a Windows 8.1 store app

Oct 26, 2014 at 10:29 PM
Edited Oct 26, 2014 at 10:49 PM
Hey!

Iam trying to get the selected item from a columnseries using Blend Behaviors, it works on a GridView but not on WinRT XAML toolkit elements like columnseries.
The project is using the Prism framework for business apps.

The following code is in the view:
            <Charting:Chart Grid.Row="1" Grid.Column="1">
                  <Charting:ColumnSeries Title="Organizations"
                                       ItemsSource="{Binding CurrentInView}"
                                       DependentValueBinding="{Binding KPIValue}"
                                       IndependentValueBinding="{Binding Name}"
                                       IsSelectionEnabled="True">
                    <interactivity:Interaction.Behaviors>
                        
                        <core:EventTriggerBehavior EventName="SelectionChanged">
                        <core:InvokeCommandAction Command="{Binding BarSelectedCommand}"
                                                              CommandParameter="{Binding Path=SelectedItem}"/>
                        </core:EventTriggerBehavior>
                    </interactivity:Interaction.Behaviors>
                </Charting:ColumnSeries>
            </Charting:Chart>
So I want to retrieve the selected item on the viewmodel like this:
public DelegateCommand<SelectionChangedEventArgs> BarSelectedCommand { get; private set; }

BarSelectedCommand = new DelegateCommand<SelectionChangedEventArgs>(NavigateInChart);

private void NavigateInChart(SelectionChangedEventArgs obj)
{
            /* .... */
}
But I get the following error:
WinRT information: Cannot add instance of type 'Microsoft.Xaml.Interactions.Core.EventTriggerBehavior' to a collection of type 'Microsoft.Xaml.Interactivity.BehaviorCollection'.
Is there any suggestions on how to solve this, that is get the selected item from the viewmodel?

Thanks!
Coordinator
Oct 27, 2014 at 6:56 PM
I'm sorry, I don't typically support questions related to the charts since I didn't write the controls (ported them from Silverlight Toolkit) and it often takes a bit of debugging on your actual app to be able to figure out what's wrong. Maybe someone else could help you here if they had a similar problem. Otherwise I'd recommend doing more debugging and binggoogling or otherwise stack overflowing for help. A self contained repro project always helps too if you need someone's help.