Monday, March 12, 2012

Microsoft CRM 2011 Silverlight: Busy Indicator Style

I was working for Microsoft CRM 2011 for more than 1 year and I like the web resource specially Silver light 4 which can used as web resource in Microsoft CRM 2011. I have really like the GUI of the Microsoft CRM 2011 and especially the control which I have design for this post " Busy Indicator". I have design the style of the Busy Indicator like the busy bar of the Microsoft CRM 2011, You can see the output in the Image 1 as shown.



 Image 1

List 1

I have created two similar type of busy indicator style and both are applied on the busy indicator control.First one is the default style which I have set and second one is the named style which you can refer by using name of the style. I have posted code for applying the style to busy indicator control as shown in List 1, Here you can see that I haven't apply any style to the first busy indicator control but for the second busy indicator control I have use the name BusyIndicatorStyle1, as there should be only one default style for one control.
You can also see in the XAML code that I have used grid layout with 2 rows of 50% 50% height and place busy indicator control in each row of the grid layout.You can download the source code of the sample from here.
You can view online sample here.
All and any comments / bugs / suggestions are welcomed!

Saturday, March 10, 2012

Select Distinct Using Linq

Problem:
              We have a list and when want to filter the list based on property to get the unique List.  

Solution:
               The solution to the above problem is very simple, as we have list and we want to get the distinct list based on some property of that list.For this code which I have used is listed in List 1 here you can see that i have an Employee class which has employee id, name and city properties, then in the main function I have declare _employeeList of type list and added records in the list. Here you can see that I have named employees with Employee A, Employee B and so on. You can see that I have place Employee A , Employee B and Employee C are duplicate and in cities I have used Islamabad, Lahore and Karachi.

List 1

Here I have get the distinct list based on two property first the name of the employee and then the based on the city. You can see in the statement where I have distinct employee list, I have first used the GroupBy of the linq and here you can notice that I have group by name of the employee as I want to get the list of unique name of the employee after the group by is the the select of the linq to get the first record of the grouped list.
Image 1
After getting the distinct employee list in var type I have used the foreach loop to display the distinct employee based on the employee name and you can see in the output that it shows only 6 records as Employee A, Employee B and Employee C has two records each so one is selected and shown. 
In the next distinct statement I have used the city , so that the resultant record are distinct on the city name and in the Image 1 you can see both the outputs.First is the distinct based on employee name and has 6 records and second is the distinct based on city and has only 3 records.
This was the way I get the distinct list based on property of the object and hope if you have similar problem then you can solve your problem by using above technique.

All and any comments / bugs / suggestions are welcomed!