绑定时出现问题,如果我绑定字符串类型Property,一切正常,但是如果我尝试绑定,则无法上传Property xaml的对象属性。
没有任何错误或警告。
Upadated模型
型号:
public class Part : BindableObject
{
public int Id { get; set; }
public string Brand { get; set; }
public string _BrandImage;
public string BrandImage
{
get { return _BrandImage; }
set
{
_BrandImage = value;
OnPropertyChanged();
}
}
public string _Name;
public string Name
{
get { return _Name; }
set
{
_Name = value;
OnPropertyChanged();
}
}
public string Article { get; set; }
public string Mfg { get; set; }
public string Image { get; set; }
public string Description { get; set; }
public List<Offer> Offers { get; set; }
};
return result;
}
}
ViewModel:
public class PartDetailViewModel : BindableBase
{
private Part part;
public Part Part
{
get { return part; }
set { SetProperty(ref part, value); }
}
public PartDetailViewModel(INavigationService navigationService)
{
Part = part.GetPartById();
}
}
答案 0 :(得分:2)
您需要继承“ BindableObject”,并将要绑定到视图的属性通知给视图有关在setter“ set {}”内更改的属性。我已经在下面修改了您的“名称”属性的代码,可以根据您对其他字段的要求进行更改。
public class Part : BindableObject
{
public int Id { get; set; }
public string Brand { get; set; }
public string BrandImage { get; set; }
private string _Name;
public string Name
{
get { return _Name; }
set
{
_Name = value;
OnPropertyChanged();
}
}
public string Article { get; set; }
public string Mfg { get; set; }
public string Image { get; set; }
public string Description { get; set; }
public List<Offer> Offers { get; set; }
}
答案 1 :(得分:0)
从模型和帮助中删除此属性
public List<Offer> Offers { get; set; }