RIA Services in Silverlight 4 Using VS 2010 Beta


Introduction

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.

RIASIL1.gif

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.

RIASIL2.gif

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

RIASIL3.gif

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

RIASIL4.gif

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.

RIASIL5.gif

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

RIASIL6.gif

RIASIL7.gif

RIASIL8.gif

RIASIL9.gif


RIASIL10.gif

RIASIL11.gif


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

RIASIL12.gif

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

RIASIL13.gif

RIASIL14.gif


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.

RIASIL15.gif

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.

RIASIL16.gif

Add the following Context and use it as shown below:

RIASIL17.gif

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

RIASIL18.gif

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.

RIASIL19.gif

Hope this article helps for the beginning.

Up Next
    Ebook Download
    View all
    Learn
    View all