This is a migrated thread and some comments may be shown as answers.

Invalid Cast - Chart.CartesianGridLineAnnotation

3 Answers 67 Views
Chart
This is a migrated thread and some comments may be shown as answers.
MiKo
Top achievements
Rank 2
MiKo asked on 22 Aug 2019, 06:43 AM

Hi,

I've tried to use the chart annotations exactly as described in this example. Unfortunately, creating the annotations and adding them to the chart from the code behind does not work. When doing so, an exception happens:

An exception of type 'System.InvalidCastException' occurred in System.Private.CoreLib.dll but was not handled in user code
Unable to cast object of type 'Telerik.XamarinForms.Chart.CartesianGridLineAnnotation' to type 'Telerik.XamarinForms.Chart.ChartSeries'.

 

As soon as I declare the annotations in XAML, it just works fine. As we need the possibility to adapt the annotations in the code behind, any support would be appreciated. 

3 Answers, 1 is accepted

Sort by
0
Didi
Telerik team
answered on 22 Aug 2019, 10:15 AM
Hello Michael,

Thank you for the provided details.

I have noticed that the example link you have send is outdated. It refers to the previous UI of the documentation. I can assure you that this will be fixed. The Chart Annotations article was reviewed and updated. You can check it at the link below:

https://docs.telerik.com/devtools/xamarin/controls/chart/chart-annotations

Regarding to the Invalid cast exception, I have created a sample and I could not reproduced the issue on my side. Please find my test project attached. Download it and give it a try.

If the issue still observes I would like to ask you to modify the attached project regarding your setup and send it back to me? In this way we could research the case further. Note that you should open a support ticket and attach the file there because in the forum only image attachments are allowed.

I hope I was helpful.

Regards,
Didi
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
MiKo
Top achievements
Rank 2
answered on 26 Aug 2019, 08:02 AM

Hi,

I've adapted the solution you provided to resemble our project. The exception occurs again.

As I can't upload *.zip files, please download the modified version from

 

0
Didi
Telerik team
answered on 26 Aug 2019, 09:46 AM
Hello,

I am sorry to hear that the exception still occurs. 

Yes, in the forum only image attachments are allowed, so I would like to ask you not to send projects in the forum in such a way. If you need to send us a project for review, please open a support ticket and attach it there. 

Thank you for the understanding.

Regards,
Didi
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Chart
Asked by
MiKo
Top achievements
Rank 2
Answers by
Didi
Telerik team
MiKo
Top achievements
Rank 2
Share this question
or