Scenario:
In this example we will create a WCF IDataStore service that will be used by our client (SilverLight Application) as a data layer. Instead of direct connection to the database, our client will connect to a remote service, which is way more secure and thus important in many enterprise scenarios as database connection settings are not exposed to the client. Also all inquiries will be performed asynchronously to not block the UI thread.
Steps to implement:
1. Implement the WCF service as shown in the How to connect to a remote data service instead of using a direct database connection example.
2. Add a new Silverlight Application project.
3. Reference DevExpress.Data and DevExpress.Xpo assemblies.
4. Implement a Customer class as shown in the example's Customer.xx file.
5. Drop GridConrtol to MainPage.
6. Modify the MainPage.xx file as shown in the example's MainPage.cs file.
The MainPage uses Dispatcher to call the BeginInitializeDataSource method asynchronously, which creates a query and uses the EnumerateAsync method to set the GridControldata source.
As a result, you will see the following page:
![]()
Important notes:
At the development stage you can face the CommunicationException. This could be due to the attempt to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You will need to publish a cross-domain policy file and ensure that it allows SOAP-related HTTP headers to be sent. Also you can simply add your Silverlight application via the "Silverlight Application" window in the WCFService property window as shown in the following screenshot:
![]()