Wpf 可观察收集<;EF4Entity>;绑定到ListView,但关系字段不';不要使ListView更新
我有一个实体框架4实体的Wpf 可观察收集<;EF4Entity>;绑定到ListView,但关系字段不';不要使ListView更新,wpf,entity-framework,data-binding,properties,observablecollection,Wpf,Entity Framework,Data Binding,Properties,Observablecollection,我有一个实体框架4实体的可观察集合绑定到列表视图。如果修改实体的任何普通标量属性,则会更新列表视图中显示的值 如果任何关系(导航)属性发生更改,则不会在列表视图中更新它们,因为实体对象不会为这些属性实现更改通知 现在,我正在从集合中删除实体,然后将其重新插入到相同的位置,以强制更新列表视图 必须有更好的解决办法。如果它存在,它是什么 以下是VS2010的EF设计器生成的代码: [EdmEntityTypeAttribute(NamespaceName="RovingAuditDb", Name=
可观察集合
绑定到列表视图
。如果修改实体的任何普通标量属性,则会更新列表视图中显示的值
如果任何关系(导航)属性发生更改,则不会在列表视图中更新它们,因为实体对象不会为这些属性实现更改通知
现在,我正在从集合中删除实体,然后将其重新插入到相同的位置,以强制更新列表视图
必须有更好的解决办法。如果它存在,它是什么
以下是VS2010的EF设计器生成的代码:
[EdmEntityTypeAttribute(NamespaceName="RovingAuditDb", Name="AuditRecord")]
[Serializable()]
[DataContractAttribute(IsReference=true)]
public partial class AuditRecord : EntityObject
{
#region Factory Method
/// <summary>
/// Create a new AuditRecord object.
/// </summary>
/// <param name="id">Initial value of the Id property.</param>
/// <param name="date">Initial value of the Date property.</param>
public static AuditRecord CreateAuditRecord(global::System.Int32 id, global::System.DateTime date)
{
AuditRecord auditRecord = new AuditRecord();
auditRecord.Id = id;
auditRecord.Date = date;
return auditRecord;
}
#endregion
#region Primitive Properties
// Deleted for this post
#endregion
#region Navigation Properties
/// <summary>
/// No Metadata Documentation available.
/// </summary>
[XmlIgnoreAttribute()]
[SoapIgnoreAttribute()]
[DataMemberAttribute()]
[EdmRelationshipNavigationPropertyAttribute("RovingAuditDb", "AuditRecordCell", "Cell")]
public Cell Cell
{
get
{
return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Cell>("RovingAuditDb.AuditRecordCell", "Cell").Value;
}
set
{
((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Cell>("RovingAuditDb.AuditRecordCell", "Cell").Value = value;
}
}
/// <summary>
/// No Metadata Documentation available.
/// </summary>
[BrowsableAttribute(false)]
[DataMemberAttribute()]
public EntityReference<Cell> CellReference
{
get
{
return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Cell>("RovingAuditDb.AuditRecordCell", "Cell");
}
set
{
if ((value != null))
{
((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedReference<Cell>("RovingAuditDb.AuditRecordCell", "Cell", value);
}
}
}
// Rest of the Navigation properties removed for this post
[EdmEntityTypeAttribute(NamespaceName=“RovingAuditDb”,Name=“AuditRecord”)]
[可序列化()]
[DataContractAttribute(IsReference=true)]
公共部分类AuditRecord:EntityObject
{
#区域工厂法
///
///创建一个新的AuditRecord对象。
///
///Id属性的初始值。
///日期属性的初始值。
公共静态AuditRecord CreateAuditRecord(全局::System.Int32 id,全局::System.DateTime日期)
{
AuditRecord AuditRecord=新的AuditRecord();
auditRecord.Id=Id;
审核记录。日期=日期;
返回审核记录;
}
#端区
#区域基本属性
//删除此帖子
#端区
#区域导航属性
///
///没有可用的元数据文档。
///
[XmlIgnoreAttribute()]
[SoapIgnoreAttribute()]
[DataMemberAttribute()]
[EdmRelationshipNavigationPropertyAttribute(“RovingAuditDb”、“AuditRecordCell”、“Cell”)]
公共小区
{
得到
{
返回((IEntityWithRelationships)this.RelationshipManager.GetRelatedReference(“RovingAuditDb.AuditRecordCell”,“Cell”).Value;
}
设置
{
((ientItyWithRelationshipManager.GetRelatedReference(“RovingAuditDb.AuditRecordCell”,“Cell”)。值=值;
}
}
///
///没有可用的元数据文档。
///
[浏览属性(错误)]
[DataMemberAttribute()]
公共实体引用单元引用
{
得到
{
返回((IEntityWithRelationships)this.RelationshipManager.GetRelatedReference(“RovingAuditDb.AuditRecordCell”,“Cell”);
}
设置
{
如果((值!=null))
{
((IEntityWithRelationship)this.RelationshipManager.InitializeRelatedReference(“RovingAuditDb.AuditRecordCell”,“Cell”,value);
}
}
}
//已删除此帖子的其余导航属性
这些实体不适用于WPF双向绑定,后者基于INotifyPropertyChanged
。我建议您看看哪些实体最适合用于客户端/服务器类型的WPF应用程序。我认为不可能“自动更新”如果对象未实现依赖属性,则显示UI。@WileyMarques-1,如果我可以。不正确。这就是INotifyPropertyChanged
的目的。让他发布代码和XAML,以便我们了解情况。哦,我的错误。我忘记了INotifyPropertyChanged
。代码是VS2010的E中自动生成的实体对象F4设计器。默认代码生成。我想我会发布自动生成的代码。啊,很有趣。我会去看看。我以前没有看过你链接到的文档,非常感谢!