如何绑定到 DomainService 上的 Invoke 操作?
我正在修改 RIA 服务,并且创建了一个 DomainService,并且能够将其绑定到网格/数据表单等...但是对于我的一生,我看不到如何在上面调用自定义方法那个域服务。我创建了一个这样的方法:
[Invoke]
public IEnumerable<string> GetCities()
{
return new List<string>() { "some city" };
}
我希望能够将组合框的项目集合绑定到该方法(单向)。
在 silverlight 页面中,有一个 peopleDomainService
对象,在将控件添加到用于绑定的页面时创建为资源。但我在上面找不到任何自定义方法。
I'm tinkering with RIA Services and I've created a DomainService and I'm able to bind that to grids/dataforms and the like... but for the life of me I can't see how I can call custom methods on that DomainService. I've created a method like this:
[Invoke]
public IEnumerable<string> GetCities()
{
return new List<string>() { "some city" };
}
I want to be able to bind the items collection of a combobox to that method (one-way).
In the silverlight page, there is a peopleDomainService
object that is created as a resource when adding controls to the page that is used for binding. But nowhere on it can I find any of my custom methods.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您所描述的没有看到该方法的方式让我想知道您是否创建了 peopleDomainService 的实例,或者您是否只是引用自动放入 XAML 中的类定义。
只要您重建了 .Web 项目,这样的事情就应该可以正常工作。
并添加 GetCities_Loaded 事件来处理结果。
The way you are describing not seeing the method makes me wonder if you have created an instance of peopleDomainService or if you are just referring to the class definition that was automatically put into the XAML.
Something like this should work fine, as long as you've rebuilt the .Web project.
And add your GetCities_Loaded event to handle the result.
假设您的调用方法位于 FooDomainService 中,您可以这样称呼它:
Assuming your invoke method is in the FooDomainService you'd call it so: