RIA Services in Silverlight 4 Using VS 2010 Beta



In this article we will see how we can filter a Textbox on Keyboard inputs. We will see how we can block Numeric input from Keyboard.

Creating Silverlight Project

Fire up Visual Studio 2010 and create a new Silverlight 4 Business Application Project. Name it as RIASilverlight4Sample01.

After creating the Project, you would see a change in Solution Structure. I meant to say that different Layers are separated from each other using different Folders.

See the below figure for the Solution Structure in VS 2010.

We will have our own Page to the Project. Add A Silverlight Page to the “View” Folder, name it as Employee.xaml.

I have added the below XAML code to have the link button in the MainPage.xaml

We would add a DataGrid to the Employee.xaml page which will be useful for our need.

Now Add An Entity Model to the Web Project.

The following screenshots are for the reference how to proceed further. You can use it as step by step.

We would change the table and field names for easy use.

Add A Domain Service Class to the Web project and name it as “EmployeeDomainService”.

If you are not getting any Entity Frameworks listed, then just press cancel and rebuild the Web Project. And do the above steps again.

You would see the EmployeeDomainService.cs file has all the methods related to CRUD operations. See the below figure.

Change the GetEmployees method to below code.

Now Re Build the solution.

Building the solution generates the Domain Context and entities in the client project.

Open Employee.xaml.cs and add the following namespaces.

Add the following Context and use it as shown below:

I have changed the DataGrid’s AutoGenerateColumns to False and made the IsReadOnly property to True. I have customized the columns structure as follows:

Now we are ready, run the application and click on the Employee Details Link on the top right. You would get the results as shown in below figure.

Hope this article helps for the beginning. J