简体   繁体   中英

Can't bind inherited property (Xamarin Cross-Platform app)

I am trying to build a xamarin cross platform app, I am trying to use a List View control, but I can't bind a public inherited property from a class. I get this console message when running the app.

This is the problem.

The class that contains the property is called Comida, which inherits from Producto class. Here are the class declarations for both Comida and Producto.This is the base class.

    public class Producto
{

    public String nombre { get; set; }
    public int precio { get; set; }
    public String usuario;
    public String descripcion="";


    public Producto(String nombre, int precio, String usuario)
    {
        this.nombre = nombre;
        this.precio = precio;
        this.usuario = usuario;
    }


}

This is the inheriting one.

    public class Comida:Producto
{

    public static readonly String SALADO = "S";
    public static readonly String DULCE = "D";
    public String tipo;


    public Comida(String nombre, int precio, String usuario, String tipo): base(nombre,precio,usuario)
    {
        this.tipo = tipo;

    }


}

通过将所需的属性添加为带有get和set的自动属性,解决了该问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM