Error Asignning a simple list to an ItemsSource

2 posts, 0 answers
  1. Amin Espinoza
    Amin Espinoza avatar
    1 posts
    Member since:
    Jul 2009

    Posted 07 Aug 2012 Link to this post

    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>)'.

  2. Rosko
    Admin
    Rosko avatar
    137 posts

    Posted 10 Aug 2012 Link to this post

    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.

  3. DevCraft banner
Back to Top