I've got an application set up with RIA Services, Entity Framework 4, and Silverlight 4. It is set up in the fashion prescribed on MSDN here: Walkthrough: Creating a RIA Services Solution
On the client side, this code loads the customer entities into a grid's Items开发者_如何学PythonSource:
public MainPage()
{
InitializeComponent();
LoadOperation<Customer> loadOp = this._customerContext.Load(this._customerContext.GetCustomersQuery());
CustomerGrid.ItemsSource = loadOp.Entities;
}
The call to "loadOp.Entities" is done asynchronously (automatically by RIA Services). How do I get notification when the asynchronous call is complete?
You need to use a callback. I haven't used the official release of RIA yet, but in the beta it was used like so.
public MainPage()
{
InitializeComponent();
LoadOperation<Customer> loadOp = this._customerContext.Load(this._customerContext.GetCustomersQuery(),MyCallback,null);
CustomerGrid.ItemsSource = loadOp.Entities;
}
private void MyCallback(LoadOperation<Customer> loadOperation)
{
//This will be called when the load is complete
}
精彩评论