【问题标题】:Can't bind inherited property (Xamarin Cross-Platform app)无法绑定继承的属性(Xamarin 跨平台应用)
【发布时间】:2018-12-07 18:03:32
【问题描述】:

我正在尝试构建一个 xamarin 跨平台应用程序,我正在尝试使用列表视图控件,但我无法绑定来自类的公共继承属性。我在运行应用程序时收到此控制台消息。

This is the problem.

包含该属性的类称为 Comida,它继承自 Producto 类。这是 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;
    }


}

这是继承的。

    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;

    }


}

【问题讨论】:

  • 请不要将代码和错误作为图片发布
  • @Jason 您好,我已将代码图像替换为实际代码,谢谢。

标签: c# xamarin inheritance binding


【解决方案1】:

通过使用 get 和 set 将所需属性添加为自动属性解决了该问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多