Silverlight datagrid 绑定嵌套对象属性

发布于 2024-11-06 02:40:12 字数 1036 浏览 0 评论 0原文

我对 Sivlerlight 世界完全陌生,所以我需要知道一件简单的事情。

如何将嵌套对象作为项目源绑定到 DataGrid。

我有一个 Employee 类,它看起来像:

Public class Employee
{
public long EmployeeId
        {
            get
            {
                return this._employeeId;
            }
            set
            {
                this._employeeId = value;

            }
        }

public string EmployeeName
        {
            get
            {
                return this._employeeName;
            }
            set
            {
                this._employeeName = value;

            }
        }

 public tblDepartment tblDepartment
        {
            get
            {

                return this._tblDepartment;
            }
            set
            {
                this._tblDepartment = value;
            }
        }
}

现在类“tblDepartment”将部门名称作为其属性之一,所以我想要实现的是在 Silverlight 的 DataGrid 中显示 EmployeeId、EmployeeName 和部门名称。我正在使用 SilverLight 4.0。

问题是我无法找到如何绑定嵌套对象属性(即对象与对象中)。

任何人都可以帮我这里,

提前谢谢。

I am totally new to Sivlerlight world, so I need to know a simple thing.

how do I bind nested object as Item Source to the DataGrid.

I have a class Employee which looks Like :

Public class Employee
{
public long EmployeeId
        {
            get
            {
                return this._employeeId;
            }
            set
            {
                this._employeeId = value;

            }
        }

public string EmployeeName
        {
            get
            {
                return this._employeeName;
            }
            set
            {
                this._employeeName = value;

            }
        }

 public tblDepartment tblDepartment
        {
            get
            {

                return this._tblDepartment;
            }
            set
            {
                this._tblDepartment = value;
            }
        }
}

now the class "tblDepartment" has Department name as its one of the properties, so what I want to achieve is show EmployeeId, EmployeeName and Department name in the DataGrid of Silverlight. I am using SilverLight 4.0.

Issue is I am not able to find how to bind Nested objects properties(i.e. Objects with in Objects).

can anyone help me out here,

thanks in advance.

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

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

发布评论

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

评论(1

一瞬间的火花 2024-11-13 02:40:12

你应该能够做到

{Binding Path=EmployeeObject.tblDepartment.Name}

You should be able to do

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