Have the problem with binding, if I bind string type Property everything work fine, but if I trying to bind in View the object property of Property xaml not upload.
No any Errors or warnings.
Upadated Model
Model:
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();
}
}
You need to inherit 'BindableObject' and notify the view about the property changed inside the setter 'set {}' for the properties that you are binding in the view. I have modified your code below for Name property, you can change based on your requirements for other fields.
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; }
}
从模型中删除此属性,多数民众赞成在帮助
public List<Offer> Offers { 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.