Hi I've xampiechart which should be connected to xamdatagrid. I mean sliceclick on piechart should filter datagrid. for that I need connect xampiechart sliceClick to the command of my view model. How can i implement event command binding for xampiechart?
Thanks
Hello Xetish,
Thank you for your post!
I have been investigating this, and it seems that simply binding to an ICommand in your ViewModel won't be enough to filter a connected XamDataGrid, mainly because you will need the event arguments of the SliceClicked event to get the data item and information about the slice that you clicked. I would recommend you to this thread on stack overflow which details a behavior you can use to pass event arguments to a command as a parameter: http://stackoverflow.com/questions/6205472/mvvm-passing-eventargs-as-command-parameter.
I have also created a sample based on the concepts presented on that thread to demonstrate one way that you could filter a XamDataGrid through exploding the slices of the XamPieChart.
I hope this helps you. Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
Thanks for help, Bye the way, for some of slieces SliceClick event args contain wrong DataContext. In my case for almost all slices eventArgs.DataContext is of type KeyValuePair<Type1, Type2> but for some of slices DataContext is of type List<KeyValuePair<Type1, Type2>>. Chart Source is bounded to Dictionaty<Type1, Type2>.
Do you have Any Idea?
Thank you for your post.
I have modified the sample that I had originally provided you to use a Dictionary<string, int> instead of the ObservableCollection<SampleData> and it appears that the only time I can reproduce this behavior you are seeing is if the particular slice that is clicked represents the "Other" category in the XamPieChart, which encapsulates multiple data items in the XamPieChart. You may be able to see if your slice falls into the "Other" category if you apply a Legend to your XamPieChart, as that particular slice's color will have the Label "Other."
If this is the case and you are looking to avoid it, you can set the OthersCategoryThreshold property on the XamPieChart to 0. This will disallow usage of the "Other" slice in the chart and it will show every slice for the chart, rather than rolling multiple data items into one slice when the data source is rather large.
Please let me know if you have any other questions or concerns on this matter.