实体图绑定无法在深层工作

发布于 2024-10-01 09:23:36 字数 612 浏览 0 评论 0原文

的实体图

假设我有像People ->Student 这样

,那么在 xaml 中,我有以下类型的绑定(People 是 VM 的属性):

<TextBox  Text="{Binding People.Name, Mode=TwoWay}" />
<TextBox  Text="{Binding People.Student.StudentNo, Mode=TwoWay}" />   <!--  this bounding is not working -->

在 VM 中,实现 IEditableObject。我有一些代码,例如:

public void BeginEdit()
{
   ((IEditableObject)this.People).BeginEdit();
   ((IEditableObject)this.People.Student).BeginEdit();    //this code not working
   //....
}

运行应用程序时,绑定到人员的所有数据都很好。

绑定到学生的所有数据都不起作用。

如何修复它?

Suppose I have entity graph like

People ->Student

then in xaml, I have following kind of binding(People is property of VM):

<TextBox  Text="{Binding People.Name, Mode=TwoWay}" />
<TextBox  Text="{Binding People.Student.StudentNo, Mode=TwoWay}" />   <!--  this bounding is not working -->

in VM, implementing IEditableObject. I have some code like:

public void BeginEdit()
{
   ((IEditableObject)this.People).BeginEdit();
   ((IEditableObject)this.People.Student).BeginEdit();    //this code not working
   //....
}

When runing the app, all data bound to People is fine.

All data bound to Student is not working.

How to fix it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我猜想 Student 属性在客户端为空。您需要将 [Include] 属性添加到服务器端的 Student 属性,以便 RIA 服务将其传递到客户端。您可能还需要为服务器端添加一个包含项以从数据库中检索它,具体取决于数据访问的编写方式。

I'd guess that the Student property is null on the client side. You need to add the [Include] attribute to the Student property on the server-side, so that it gets taken across to the client side by RIA services. You may also need to add an include for your server-side to retrieve it from the database, depending on how your data-access is written.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文