MAUI XAML页面绑定报错XFC0045:找不到Note模型的NoteDescription属性
解决MAUI中XFC0045绑定错误:Property "NoteDescription" not found on "Notas.Models.Note"
核心问题出在你的Note模型类中:NoteDescription是字段(field)而非属性(property),MAUI的数据绑定机制仅支持绑定到带有get/set访问器的属性,无法直接识别字段。
修改模型代码
将Note类中的字段改为自动属性,添加get和set访问器即可解决错误:
using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Notas.Model { [Table("Notes")] public class Note : BaseEntity { [MaxLength(250)] public string NoteDescription { get; set; } // 改为属性,添加get/set访问器 } }
补充说明
移除x:DataType后错误仍存在,是因为MAUI的绑定系统在编译时和运行时都会验证绑定目标的成员合法性,字段本身不符合绑定要求,所以必须转换为属性才能被绑定系统识别。
内容的提问来源于stack exchange,提问作者Sam
相关产品推荐
相关产品推荐

