Silverlight WCF 服务绑定到网格 - 网格为空白...我错过了什么吗?

发布于 2024-07-21 23:59:05 字数 1175 浏览 7 评论 0原文

这是我的情况 - 我正在从 Windows 背景启动我的第一个 SL 应用程序,其中我已经设置了 MVC 模式。 我想我可以利用这个模式,所以我直接开始创建一个包含 3 个项目的 SL 应用程序(解决方案)--> 1 个持有我的模型(之前的业务对象)、SL 应用程序(当我选择 SL 项目时自动生成)和 1 个 SL.Web 项目(当我选择 SL 项目时自动生成)。

以下是我所做的步骤:我将一个空白网格放入我的 xaml 文件中,创建了一个服务,并且它被识别,没有任何问题。 向我的 Web 项目添加了“启用 Silverlight 的 WCF 服务”,并在我的项目中引用了我的“模型”项目。 在 [OperationContract] 中,我创建了以下方法(服务):

[OperationContract]
public EmployeeCollection GetEmployees()
{
     EmployeeCollection employees = Model.EmployeeCollection.GetAllEmployees();
     return employees;
}

当我对此进行调试并设置断点时,我确实看到了员工返回的数据,因此我知道正在返回数据。

现在,在我的 page.xaml.cs 文件上,似乎我的网格没有以某种方式填充,但不知道为什么。

我有以下片段:

void MyWebService_GetEmploteesCompleted(object sender, EmployeeWebService.GetEmployeesCompletedEventArgs e)
{
     dataGrid.ItemsSource = e.Result;
}

我还应该在哪里寻找? 我可以缺少什么吗? 我是否需要添加其他代码片段才能与我的 BLL(模型)一起工作?

感谢您的任何建议。

=============================

顺便说一句,在调试时,在“自动”窗口中,我注意到 _GetEMployeesCompleted 上出现以下值():

dataGrid.ItemSource ........................ 计数 = 30 e.Result ...... Count = 30

为什么值没有显示在我的 DataGrid 上?

Here's my situation - I am starting my first SL application coming from a Windows background where I have the MVC pattern in place. I am thinking I can take advantage of tha pattern, so I jump right in to creating a SL application (solution) with 3 projects --> 1 holding my Model (business objects from before), SL app (automatically generated when I picked SL project), and 1 SL.Web project (automatically generated when I picked SL project).

Here are the steps I did: I dropped a blank grid onto my xaml file, created a service and it is being recognized w/o any problems. Added a "Silverlight-enabled WCF Service" to my Web project and w/in my project I referenced my "Model" project. Within [OperationContract], I created the following method (service):

[OperationContract]
public EmployeeCollection GetEmployees()
{
     EmployeeCollection employees = Model.EmployeeCollection.GetAllEmployees();
     return employees;
}

When I debug though this and put a breakpoint, I DO see data on return of employees, so I KNOW data is being returned.

Now, on my page.xaml.cs file, it seems that that my grid is not being populated somehow, but don't why.

I have the following snippet:

void MyWebService_GetEmploteesCompleted(object sender, EmployeeWebService.GetEmployeesCompletedEventArgs e)
{
     dataGrid.ItemsSource = e.Result;
}

Where else should I be looking? What can I be missing? Do I have to add other snippets of code to work w/ my BLL (Model)?

Thanks for any advice.

=============================

BTW, while debugging, in the "Autos" window, I notice the following values coming through on _GetEMployeesCompleted():

dataGrid.ItemSource ........... Count = 30
e.Result ......... Count = 30

Why aren't the values showing up on my DataGrid?

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

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

发布评论

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

评论(3

上课铃就是安魂曲 2024-07-28 23:59:05

您是否在 DataGrid 上设置了 AutoGenerateColumns = true ? EmployeeCollection 实现了哪些接口?

Did you set AutoGenerateColumns = true on the DataGrid? What interfaces does EmployeeCollection implement?

海之角 2024-07-28 23:59:05

请原谅这个愚蠢的问题,但由于我们没有看到 Employee 类是如何实现的,您的 Employee 类是否公开了公共属性(而不仅仅是公共成员)? 您只能绑定到属性,这可能解释了为什么 DataGrid 不自动生成列。

Pardon the silly question, but since we don't see how the Employee class is implemented, does your Employee class expose public properties (not just public members)? You can only bind to properties, that might explain why DataGrid is not auto generating columns.

假扮的天使 2024-07-28 23:59:05

这个问题有点老了,但我遇到了类似的问题......

你使用主题引擎吗? 我注意到,在主题引擎中使用另一个控件(ChildWindow、Tab 等)内部的网格会导致子项无法渲染。 我已经向工具包人员提出了一个错误,所以我们将看看它是否得到修复。

This question is a bit old, but I've ran into a similar problem...

Are you using the theme engine? I've noticed that using the grid inside of another control (ChildWindow, Tab, etc) with the Theme Engine causes the children to not render. I've raised a bug with the toolkit people, so we'll see if it gets fixed.

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