How to: Create an Asynchronous Windows Presentation Framework Application (WCF Data Services)


With WCF Data Services, you can bind data obtained from a data service to UI element of a Windows Presentation Framework (WPF) application. For more information, see Binding Data to Controls.You can also execute operations against the data service in an asynchronous manner, which enables the application to continue to respond while waiting for a response to a data service request. Applications for Silverlight are required to access the data service asynchronously. For more information, see Asynchronous Operations.

This topic shows how to access a data service asynchronously and bind the results to elements of a WPF application. The examples in this topic use the Northwind sample data service and autogenerated client data service classes. This service and the client data classes are created when you complete the WCF Data Services quickstart.

The following XAML defines the window of the WPF application.

[!CODE [Astoria Northwind Client#WpfDataBindingAsyncXaml](../CodeSnippet/VS_Snippets_Misc/astoria northwind client#wpfdatabindingasyncxaml)]

The following code-behind page for the XAML file executes an asynchronous query by using the data service and binds the results to elements in the WPF window.

[!CODE [Astoria Northwind Client#WpfDataBindingAsync](../CodeSnippet/VS_Snippets_Misc/astoria northwind client#wpfdatabindingasync)]

WCF Data Services Client Library