简体   繁体   English

无法绑定继承的属性(Xamarin跨平台应用程序)

[英]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. 我正在尝试构建xamarin跨平台应用程序,正在尝试使用列表视图控件,但是我无法从类中绑定公共继承的属性。 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. 包含该属性的类称为Comida,该类继承自Producto类。 Here are the class declarations for both Comida and Producto.This is the base class. 这是Comida和Producto的类声明。这是基类。

    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的自动属性,解决了该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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