Wednesday, April 27, 2011

DataPager Using MVVM in Silverlight 4

In this short post I will show you how to use the DataPager control using MVVM pattern in silverlight. I have develop navigation application for this example which you can see as shown in the Image 1. Here you can see that I have two control in the home screen one is the DataGrid and the second one is the DataPager control.

Image 1
In ViewModel I have only property with the name CustomerList of type PagedCollectionView. I have data store in the xml file with the name of customer which is store in the DataBase folder. I have read the xml file in the constructor of the ViewModel and then populate each record in the List.

List 1
In the List 1 you can see that I have created collection of customer list and then populate the customer list with the records which are read from the xml file. After reading the xml file and populating the customer list at the end of the constructor I have created the new PagedCollectionView and pass the local customer list and assigned to the Customer List property as you can see in the List 1.

Image 2
In the View of the home page what I have done is to bind the ItemSource of the DataGrid property to the CustomerList property and then I have used the ItemSource property to be bind with the Source property of the DataPager which you can see in the Image 2. You can also bind the CustomerList property of the ViewModel with the Source property of the DataPage it will work as it is working with the ItemSource property of the DataGrid. You can download the source code from here 

All and any comments / bugs / suggestions are welcomed!

Wednesday, April 20, 2011

Disable Field In Microsoft CRM 2011

As I have shifted to Microsoft CRM 2011 due to change of my job. Now I will give you some tips regarding MS CRM 2011 from here onword and also Silverlight as well because of the nature of the job. Here is my first post regarding MS CRM 2011 which is how to disabled field on the form using javascript. The code is listed below

List 1
In the List 1 you can see I have define a javascript function which will take two parameter with the name of pickListName and the fieldName. picklistName is the name of the picklist which is used to enabled disabled the field. I have 2 values in the pickList based on the selected value I have endabled disabled the field on the form. First I have check for the null value as I have added empty string in the picklist for no selection.

All and any comments / bugs / suggestions are welcomed!