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

Error Asignning a simple list to an ItemsSource

1 Answer 86 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Amin Espinoza
Top achievements
Rank 1
Amin Espinoza asked on 08 Aug 2012, 02:53 AM
Hi, this is my problem. I have this. on my code behind

class Producccion

{

public int Periodo { get; set; }

public int Cantidad { get; set; }

}

public void CrearDatos()

{

ObservableCollection<Producccion> listaProduccion = new ObservableCollection<Producccion>();

listaProduccion.Clear();

listaProduccion.Add(new Producccion { Periodo = 1, Cantidad = 2556 });

listaProduccion.Add(new Producccion { Periodo = 2, Cantidad = 2558 });

listaProduccion.Add(new Producccion { Periodo = 3, Cantidad = 2654 });

listaProduccion.Add(new Producccion { Periodo = 4, Cantidad = 2354 });

SeriesMapping serie1 = new SeriesMapping();

serie1.SeriesDefinition = new LineSeriesDefinition();

serie1.SeriesDefinition.ShowItemToolTips = true;

serie1.ItemMappings.Add(new ItemMapping("Periodo", DataPointMember.XValue));

serie1.ItemMappings.Add(new ItemMapping("Cantidad", DataPointMember.YValue));

graficoControl.SeriesMappings.Add(serie1);

graficoControl.ItemsSource = listaProduccion;

}



And then I get this error.



Message: System.MethodAccessException: Error al intentar el método 'System.Linq.EnumerableQuery.Create(System.Type, System.Collections.IEnumerable)' obtener acceso al método 'System.Linq.EnumerableQuery`1<System.__Canon>..ctor(System.Collections.Generic.IEnumerable`1<System.__Canon>)'.

1 Answer, 1 is accepted

Sort by
0
Rosko
Telerik team
answered on 10 Aug 2012, 08:19 AM
Hello Amin,

The problem is coming from the security restrictions of your class. By default, every class is with private security modifies. You need to make it public.

public class Producccion
{
   public int Periodo { get; set; }
   public int Cantidad { get; set; }
}


Greetings,
Rosko
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Chart
Asked by
Amin Espinoza
Top achievements
Rank 1
Answers by
Rosko
Telerik team
Share this question
or