I was wondering, if there is a property I can bind to get the selected item.
I use the slice option and would like to fill the SideDrawers content according to the selected item.
I know there is a SelectionChanged somethere, I was just wondering, if there is a property I can bind to instead.
4 Answers, 1 is accepted
I played around a littlebit more and tried to add a command which fires when I select something.
Unfortunately something is not working as I thought. My "Command" is always NULL and thus will not get fire.
The XAML part:
Here is my custom "ChartSelectionBehavior" implementation:
I think that the Command is null because in the OnSelectionChanged method the BindingContext is set to null. Once you remove that line, the command will be raised as desired.
You can get the selected data points from the SelectedPoints property of the behavior. From the DataPoint you can get the original item from the DataItem property.
I hope you find this information helpful.
I figured out, that the BindingContext doesn't appear to be set. It kinda is a bug.
You have to use some sort of hack like this, overiding the OnParentSet method and getting parents context for further usage.
Good luck for all the people that need such a workaround.
After a more thorough investigation I can confirm that you are correct and indeed there is a bug in the chart. The binding context does not seem to be propagated to the behavior in all cases. This prevents the Binding from kicking in and as a result the Command is null. I have logged this in our feedback portal where you can track its status.
After some consideration, the dev team agreed that right now the MVVM support for selected items is not very satisfactory. This is why I logged a feature request for implementing an option for achieving such a scenario in a more straightforward way.
I have updated your Telerik points as a sign of gratitude for letting us know of the issue and giving us an idea about how to improve our products. Let us know if you have any questions.