We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Cannot cast from source type to destination type.

Thread ID:

Created:

Updated:

Platform:

Replies:

120157 Sep 6,2015 01:00 PM Sep 7,2015 01:19 AM Android 1
loading
Tags: SfChart
Federico Navarrete
Asked On September 6, 2015 01:00 PM

I'm having some troubles trying to initialize a variable always when I try to do it with the SfChart I get this error: "Cannot cast from source type to destination type."

This is my code: 

XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:syncfusion="clr-namespace:Syncfusion.SfChart.Android;assembly:Syncfusion.SfChart.Android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <com.syncfusion.charts.SfChart    
        android:id="@+id/chartWeeklyResult"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1">
</com.syncfusion.charts.SfChart>
</LinearLayout>

C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Com.Syncfusion.Charts;
using Com.Syncfusion.Charts.Enums;
using Android.Graphics;

namespace Stop_Diabetes_Android
{
[Activity (Label = "Statistics")]
public class StatisticsActivity : Activity
{
private SfChart chartIn;

protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
SetContentView(Resource.Layout.Statistics);

try{
chartIn = (SfChart) FindViewById (Resource.Id.chartWeeklyResult);

}
catch (Exception ex) {
}
}
}
}

I'd like to know if someone know how to fix it. Thanks for your worthy time and help.

Yuvaraj Palanisamy [Syncfusion]
Replied On September 7, 2015 01:19 AM

Hi Federico,

Thanks for using Syncfusion products.

Please use the following code example to get the chart reference from layout.

Code Example [C#]

chartln = FindViewById<SfChart>(Resource.Id.chartWeeklyResult);



Regards,
Yuvaraj

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;