<?xml version="1.0" encoding="UTF-8" standalone="no"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:gd="http://schemas.google.com/g/2005" xmlns:georss="http://www.georss.org/georss" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-5765821788458763196</atom:id><lastBuildDate>Wed, 27 May 2026 15:28:26 +0000</lastBuildDate><category>SilverLight</category><category>WPF</category><category>MS CRM 2011</category><category>MVVM</category><category>Javascript</category><category>Jquery</category><category>Nice Article</category><category>Javascript And Asp.net</category><category>Asp.net</category><category>Learning C#</category><category>Coding Practice</category><category>Sql Server</category><category>Visual Studio</category><category>Jquery and Asp.net</category><category>VB.Net</category><category>About Me</category><category>Linq</category><title>Asim Sajjad</title><description>How you think about a problem
is more important than the problem itself</description><link>http://asimsajjad.blogspot.com/</link><managingEditor>noreply@blogger.com (Asim Sajjad)</managingEditor><generator>Blogger</generator><openSearch:totalResults>238</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><language>en-us</language><itunes:explicit>no</itunes:explicit><itunes:summary>How you think about a problem is more important than the problem itself</itunes:summary><itunes:subtitle>How you think about a problem is more important than the problem itself</itunes:subtitle><itunes:owner><itunes:email>noreply@blogger.com</itunes:email></itunes:owner><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5765821788458763196.post-1179479638861260115</guid><pubDate>Mon, 31 Dec 2012 02:37:00 +0000</pubDate><atom:updated>2013-01-25T08:42:56.092+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">MS CRM 2011</category><category domain="http://www.blogger.com/atom/ns#">SilverLight</category><title>Reading Organization Setting</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Problem:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Need to read organization settings
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Solution:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; To read the organization information like what is the maximum size of the file which can be uploaded? , Currency format code and currency symbol (like ($) dollar sign for USA etc), date and time format string for organization level, and fiscal year related information etc, we need to read the organization entity to get these and other organization related attributes.

&lt;/div&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnEUad-EsStFSQmw3d_e613LKRWKvbrSpDcRQ4CnaqyYAf3KiMEHhc-IwDAIMR3CKNYZF1eWTF9sV2j28nXb-VA_pIAUM-o8L0SV-UsTTs-d5z5oghV6Cj2Ulzb6irMOMeWZjbhiiC-8E/s1600/1-5-2013+7-31-43+AM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="224" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnEUad-EsStFSQmw3d_e613LKRWKvbrSpDcRQ4CnaqyYAf3KiMEHhc-IwDAIMR3CKNYZF1eWTF9sV2j28nXb-VA_pIAUM-o8L0SV-UsTTs-d5z5oghV6Cj2Ulzb6irMOMeWZjbhiiC-8E/s400/1-5-2013+7-31-43+AM.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 1&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
Code for the reading organization is listed in &lt;i&gt;List 1&lt;/i&gt;, here you can see that it is simple query expression which read all the columns and no user based condition which I have added while reading the &lt;a href="http://asimsajjad.blogspot.com/2012/12/reading-user-settings-by-user-id.html" target="_blank"&gt;User setting &lt;/a&gt;(Where I have used the current user id to get the user settings).
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
&lt;![CDATA[
        public void getEntityRecord() {
            try {
                QueryExpression queryExpression = new QueryExpression();

                //set the entity name
                queryExpression.EntityName = EntityName;              

                //add the attribute name which are used to fetch from the entity name.
                queryExpression.ColumnSet = new ColumnSet();
                queryExpression.ColumnSet.AllColumns = true;


                OrganizationRequest organizationRequest = new OrganizationRequest() { RequestName = "RetrieveMultiple" };
                organizationRequest["Query"] = queryExpression;

                IOrganizationService organizationService = SilverlightUtility.GetSoapService();
                organizationService.BeginExecute(organizationRequest, new AsyncCallback(getEntityRecord_ClickCallback), organizationService);
                BusyContent = string.Format("Loading {0} Entity record...", EntityName);
                IsBusy = true;
            }
            catch (Exception Ex) {
                MessageText = string.Format("Error : {0}", Ex.Message);
            }
        }
]]&gt;
&lt;/script&gt;

&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 1&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
After the call is send and it return control is shifted to "getEntityRecord_ClickCallback" call back to process the return value from the request. Code is listed in &lt;i&gt;List 2&lt;/i&gt;, here you can see that I have used to for each loop on the list which contains the meta data of the organization setting entity. Here I fist check for if the entity contains attribute or not and then check the attribute type whether attribute is pick list or lookup type because to get value of the lookup and pick list is different.If you get the value of the pick list then it will give you integer part of the pick list and we need the string value of the pick list to be displayed. Here you can see that I have get the integer value of the pick list in local variable and then search for the string value of the pick list in the list ( I have also save pick list option set in local list of the record so that I don’t need to make another MS CRM call to get option sets of the particular pick list, you can also see the code of the call back of the meta data request of the organization setting entity for reference).
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
&lt;![CDATA[
        private void getEntityRecord_ClickCallback(IAsyncResult result) {
            Deployment.Current.Dispatcher.BeginInvoke
                   (
                       (() =&gt;
                       {
                           try {
                               OrganizationResponse organizationResponse = ((IOrganizationService)result.AsyncState).EndExecute(result);
                               EntityCollection entityResults = (EntityCollection)organizationResponse["EntityCollection"];

                               if (entityResults.Entities.Count == 0)
                                   MessageText = "There are no Account records in the system.";

                               foreach (Entity entity in entityResults.Entities) {

                                   foreach (EntityMetadataRecord _currentRow in _entityMetadataList) {
                                       if (entityResults.Entities[0].Attributes.ContainsKey(_currentRow.LogicalName)) {
                                           switch (_currentRow.Type.ToLower().Trim()) {
                                               case "picklist":
                                               int? _OptionSetValue = ((OptionSetValue)entityResults.Entities[0][_currentRow.LogicalName]).Value;
                                               var _selectedOptionSet = _currentRow.OptionSet.Where(para =&gt; para.Value == _OptionSetValue).ToList();
                                               if (_selectedOptionSet.Count != 0) {
                                                   _currentRow.DisplayValue = _selectedOptionSet[0].Label;
                                               }
                                               break;
                                               case "lookup":
                                               _currentRow.DisplayValue = ((EntityReference)entityResults.Entities[0][_currentRow.LogicalName]).Name.ToString();
                                               break;
                                               default:
                                               _currentRow.DisplayValue = entityResults.Entities[0][_currentRow.LogicalName].ToString();
                                               break;
                                           }//end of switch block

                                       }
                                   }

                                   for (int _counter = _entityMetadataList.Count - 1; _counter &gt; 0; _counter--) {
                                       if (string.IsNullOrEmpty(_entityMetadataList[_counter].DisplayValue)) {
                                           _entityMetadataList.Remove(_entityMetadataList[_counter]);
                                       }
                                   }
                               }
                               EntityMetadataList.Refresh();
                               RecordInformation = string.Format("1 - {0} of {0} (0 Selected)", _entityMetadataList.Count);
                           }
                           catch (Exception Ex) {
                               MessageText = string.Format("Error : {0}", Ex.Message);
                           }
                           IsBusy = false;
                       })
                   );
        }
]]&gt;
&lt;/script&gt;

&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 2&lt;/b&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
This was all how to get the organization setting to get organization setting. You can download source
code and CRM 2011 solution for testing and modification from the links which
are given below.&lt;/div&gt;
&lt;b&gt;Downloads&lt;/b&gt;&lt;br /&gt;
You can download the source code of the sample from &lt;a href="http://asimsajjad.googlecode.com/files/Account%20Grid%20V%201.0.10.zip"&gt;&lt;span style="color: #2181b7;"&gt;here&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;
and working CRM 2011 solution from &lt;a href="http://asimsajjad.googlecode.com/files/AccountGrid_1_0_10_0.zip"&gt;here&lt;/a&gt;. 
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;
&lt;a href="http://asimsajjad.blogspot.com/2012/09/using-query-expression-in-silverlight.html" target="_blank"&gt;Go to Home&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;All 
and any comments / bugs / suggestions are welcomed!&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://asimsajjad.blogspot.com/2012/12/reading-organization-setting.html</link><author>noreply@blogger.com (Asim Sajjad)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnEUad-EsStFSQmw3d_e613LKRWKvbrSpDcRQ4CnaqyYAf3KiMEHhc-IwDAIMR3CKNYZF1eWTF9sV2j28nXb-VA_pIAUM-o8L0SV-UsTTs-d5z5oghV6Cj2Ulzb6irMOMeWZjbhiiC-8E/s72-c/1-5-2013+7-31-43+AM.png" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5765821788458763196.post-2714470995409535085</guid><pubDate>Sun, 30 Dec 2012 02:28:00 +0000</pubDate><atom:updated>2012-12-30T07:29:29.472+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">MS CRM 2011</category><category domain="http://www.blogger.com/atom/ns#">SilverLight</category><title>Reading User Settings by User Id</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Problem:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Need to read user setting so that we can use some of the user setting like time zone to display correct time for the log-in user if our portal is use MS CRM 2011 user name and password to log-in.
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Solution:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; To get login user setting like time format, date format, date separator, time separator, number separator and time zone code etc we need to read the "usersettings" entity. You can see the main screen of the sample application in &lt;i&gt;image 1&lt;/i&gt; here you can see that I have displayed all attributes of the user setting entity in data grid control. Here first I have retrieved the meta data of the user settings entity and then based on the current login user id I have retrieved the settings of the user from the MS CRM.

&lt;/div&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDOJNzWjXHKI8NvlIVnQWNTGpOeFrzoW4u16Yka9Mn19zmBZSmfdx8vMXPpMsUjlA55jKByCq2RNDZ1PCKF9InlpRU5qMfjsoTnEsy1tqWLERaW36QS5vuo0dcX1OZpro2BHcNVqQd6Ww/s1600/12-23-2012+7-25-03+AM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="224" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDOJNzWjXHKI8NvlIVnQWNTGpOeFrzoW4u16Yka9Mn19zmBZSmfdx8vMXPpMsUjlA55jKByCq2RNDZ1PCKF9InlpRU5qMfjsoTnEsy1tqWLERaW36QS5vuo0dcX1OZpro2BHcNVqQd6Ww/s400/12-23-2012+7-25-03+AM.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 1&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Let me discuss code in the list &lt;i&gt;List 1&lt;/i&gt;, here you can see that I have function “getEntityRecord“  which takes entity name as parameter and is called when the meta data request for the entity is completed and attributes are added in the collection.Here you can see that I have assigned passed entity name to the query expression object and then I just created on condition to set the system user id Guid. Here you can see that I have JavaScript to get the current login user id and then add to values of the condition. And then add that condition to the query expression object and set all columns of the query expression object to true as I want to get all the columns of the user setting entity
&lt;/div&gt;
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
&lt;![CDATA[
        public void getEntityRecord(string entityName) {
            try {
                QueryExpression queryExpression = new QueryExpression();

                //set the entity name
                queryExpression.EntityName = entityName;

                //  Query using ConditionExpression
                ConditionExpression _stateCodeCondition = new ConditionExpression();
                _stateCodeCondition.AttributeName = "systemuserid";
                _stateCodeCondition.Operator = ConditionOperator.Equal;
                _stateCodeCondition.Values.Add((string)HtmlPage.Window.Eval("window.parent.Xrm.Page.context.getUserId()"));

                FilterExpression _filterExpression = new FilterExpression();
                _filterExpression.FilterOperator = LogicalOperator.And;
                _filterExpression.Conditions.Add(_stateCodeCondition);

                queryExpression.Criteria = new FilterExpression();
                queryExpression.Criteria.Filters.Add(_filterExpression);

                //add the attribute name which are used to fetch from the entity name.
                queryExpression.ColumnSet = new ColumnSet();
                queryExpression.ColumnSet.AllColumns = true;


                OrganizationRequest organizationRequest = new OrganizationRequest() { RequestName = "RetrieveMultiple" };
                organizationRequest["Query"] = queryExpression;

                IOrganizationService organizationService = SilverlightUtility.GetSoapService();
                organizationService.BeginExecute(organizationRequest, new AsyncCallback(getEntityRecord_ClickCallback), organizationService);
                BusyContent = string.Format("Loading {0} Entity record...", "usersettings");
                IsBusy = true;
            }
            catch (Exception Ex) {
                MessageText = string.Format("Error : {0}", Ex.Message);
            }
        }
]]&gt;
&lt;/script&gt;

&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 1&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
After the call is send and it return control is shifted to "getEntityRecord_ClickCallback" call back to process the return value from the request. Code is listed in &lt;i&gt;List 2&lt;/i&gt;, here you can see that I have used to for each loop on the list which contains the meta data of the user setting entity.As I have retrieved record based on the current logged in user so I will get only access the entity by 0(zero) index. Here I fist check for if the entity contains attribute or not and then check the attribute type whether attribute is pick list or lookup type because to get value of the lookup and pick list is different.If you get the value of the pick list then it will give you integer part of the pick list and we need the string value of the pick list to be displayed. Here you can see that I have get the integer value of the pick list in local variable and then search for the string value of the pick list in the list ( I have also save pick list option set in local list of the record so that I don’t need to make another MS CRM call to get option sets of the particular pick list, you can also see the code of the call back of the meta data request of the user setting entity for reference).
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
&lt;![CDATA[
        private void getEntityRecord_ClickCallback(IAsyncResult result) {
            Deployment.Current.Dispatcher.BeginInvoke
                   (
                       (() =&gt;
                       {
                           try {
                               OrganizationResponse organizationResponse = ((IOrganizationService)result.AsyncState).EndExecute(result);
                               EntityCollection entityResults = (EntityCollection)organizationResponse["EntityCollection"];

                               if (entityResults.Entities.Count == 0)
                                   MessageText = "There are no Account records in the system.";

                               foreach (Entity entity in entityResults.Entities) {

                                   foreach (EntityMetadataRecord _currentRow in _entityMetadataList) {
                                       if (entityResults.Entities[0].Attributes.ContainsKey(_currentRow.LogicalName)) {
                                           switch (_currentRow.Type.ToLower().Trim()) {
                                               case "picklist":
                                               int? _OptionSetValue = ((OptionSetValue)entityResults.Entities[0][_currentRow.LogicalName]).Value;
                                               var _selectedOptionSet = _currentRow.OptionSet.Where(para =&gt; para.Value == _OptionSetValue).ToList();
                                               if (_selectedOptionSet.Count != 0) {
                                                   _currentRow.DisplayValue = _selectedOptionSet[0].Label;
                                               }
                                               break;
                                               case "lookup":
                                               _currentRow.DisplayValue = ((EntityReference)entityResults.Entities[0][_currentRow.LogicalName]).Name.ToString();
                                               break;
                                               default:
                                               _currentRow.DisplayValue = entityResults.Entities[0][_currentRow.LogicalName].ToString();
                                               break;
                                           }//end of switch block

                                       }
                                   }

                                   for (int _counter = _entityMetadataList.Count - 1; _counter &gt; 0; _counter--) {
                                       if (string.IsNullOrEmpty(_entityMetadataList[_counter].DisplayValue)) {
                                           _entityMetadataList.Remove(_entityMetadataList[_counter]);
                                       }
                                   }
                               }
                               EntityMetadataList.Refresh();
                               RecordInformation = string.Format("1 - {0} of {0} (0 Selected)", _entityMetadataList.Count);
                           }
                           catch (Exception Ex) {
                               MessageText = string.Format("Error : {0}", Ex.Message);
                           }
                           IsBusy = false;
                       })
                   );
        }
]]&gt;
&lt;/script&gt;

&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 2&lt;/b&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Next is to get the value of the lookup type, for the lookup I have just convert it to entity reference type and then get the name of the lookup.  In default case I have used normal way to get the value of the other type like interger, strings etc.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;b&gt;Note:&lt;/b&gt;I have also save the type of attribute in the collection so that to make the decision of pick list and lookup to get value (for reference you can see the code of the meta data call back in the sample application).
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/i&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Downloads&lt;/b&gt;&lt;br /&gt;
You can download the source code of the sample from &lt;a href="http://asimsajjad.googlecode.com/files/Account%20Grid%20V%201.0.9.zip"&gt;&lt;span style="color: #2181b7;"&gt;here&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;
and working CRM 2011 solution from &lt;a href="http://asimsajjad.googlecode.com/files/AccountGrid_1_0_9_0.zip"&gt;here&lt;/a&gt;. 
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;
&lt;a href="http://asimsajjad.blogspot.com/2012/09/using-query-expression-in-silverlight.html" target="_blank"&gt;Go to Home&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;All 
and any comments / bugs / suggestions are welcomed!&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://asimsajjad.blogspot.com/2012/12/reading-user-settings-by-user-id.html</link><author>noreply@blogger.com (Asim Sajjad)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDOJNzWjXHKI8NvlIVnQWNTGpOeFrzoW4u16Yka9Mn19zmBZSmfdx8vMXPpMsUjlA55jKByCq2RNDZ1PCKF9InlpRU5qMfjsoTnEsy1tqWLERaW36QS5vuo0dcX1OZpro2BHcNVqQd6Ww/s72-c/12-23-2012+7-25-03+AM.png" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5765821788458763196.post-1237266144109223132</guid><pubDate>Sun, 16 Dec 2012 03:00:00 +0000</pubDate><atom:updated>2012-12-16T08:02:04.825+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">MS CRM 2011</category><category domain="http://www.blogger.com/atom/ns#">SilverLight</category><title>Reading OptionSet Items Key/value Using MetaData Request</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Problem:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sometimes we need to get the option set key value pair to display in web resource like Silverlight etc or sometimes we have option set key but we need to display value (which is the string type display in option set).&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Solution:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; When creating web resource for MS CRM 2011 there are some situations when we need to display one of the option set in combo box or in dropdown html control so that user can select any of the option from the combo box or from dropdown control. In order to get option set item we need to make meta data call which can return number of item of that field of entity.You can see the screen of the sample application in &lt;i&gt;Image 1&lt;/i&gt;; here you can see that I have continue my last &lt;a href="http://asimsajjad.blogspot.com/2012/12/retrieve-entity-attributes-metadata.html" target="_blank"&gt;post &lt;/a&gt;where I have display entity attribute meta data for this sample I have displayed on option set attributes and also added data grid control to display option set items.
&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg90ic8HVwalYq1cb8g7P2hTX9qJyzyvFtjYoVknUbxJ3lZWKuksmnrXZDaiIR2MjbLc0CqBzcBlWv_YpLIHDuipcCXz4xwIqPv8acuNPbyy26JBttivcKTAms8qCO-K-8yBLmegL7wl_s/s1600/Default.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="224" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg90ic8HVwalYq1cb8g7P2hTX9qJyzyvFtjYoVknUbxJ3lZWKuksmnrXZDaiIR2MjbLc0CqBzcBlWv_YpLIHDuipcCXz4xwIqPv8acuNPbyy26JBttivcKTAms8qCO-K-8yBLmegL7wl_s/s400/Default.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 1&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style="text-align: justify;"&gt;
Let us discuss code which is used to get the option set items from by using meta data request You can see the code in &lt;i&gt;List 1&lt;/i&gt; you can see the function which is used to get the items "getOptionSetLabels", function will take entity schema name and also the schema name of the option set attribute and display name of the option set attribute which will be displayed while showing busy bar.&lt;br /&gt;
Here you can see that first property of the request is the request name is "RetreiveAttributes" and the second property which is set is logical name of the entity, and I have used entity name which is passed to the function and then is the logical name which is the schema name of the option set attribute which is also passed to the function. Both entity name and the attribute name(which is the option set ) are schema names.
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
&lt;![CDATA[
        public void getOptionSetLabels(string pstrEntityName, string pstAttributeName, string DisplayName) {
            _optionSetItems.Clear();
            OrganizationRequest organizationRequest = new OrganizationRequest();
            organizationRequest.RequestName = "RetrieveAttribute";
            organizationRequest["EntityLogicalName"] = pstrEntityName;
            organizationRequest["LogicalName"] = pstAttributeName;
            organizationRequest["MetadataId"] = Guid.Empty;
            organizationRequest["RetrieveAsIfPublished"] = true;
            IOrganizationService organizationService = SilverlightUtility.GetSoapService();
            BusyContent = string.Format("Loading {0} OptionSets...", DisplayName);
            IsBusy = true;
            organizationService.BeginExecute(organizationRequest, new AsyncCallback(getOptionSetLabelsCompleted), organizationService);
        }
]]&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 1&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Code in &lt;i&gt;List 1&lt;/i&gt;, I have mentioned important properties of the request, now when the request return call back event handler is executed and here you can see I just get the option set meta data to loop through and get all the option set item as code is listed in&lt;i&gt; List 2&lt;/i&gt;.
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
&lt;![CDATA[
        private void getOptionSetLabelsCompleted(IAsyncResult result) {
            Deployment.Current.Dispatcher.BeginInvoke
                    (
                        (() =&gt;
                        {
                            OrganizationResponse response = ((IOrganizationService)result.AsyncState).EndExecute(result);
                            if (response != null &amp;&amp; response.Results.Count &gt; 0) {
                                OptionSetMetadata optionSetMetadata = ((EnumAttributeMetadata)(response.Results[0].Value)).OptionSet;
                                //Set the metadata object in required field                 
                                for (int intCounter = 0; intCounter &lt; optionSetMetadata.Options.Count; intCounter++) {
                                    _optionSetItems.Add(new OptionSetRecord()
                                    {
                                        Value = optionSetMetadata.Options[intCounter].Value,
                                        Label = optionSetMetadata.Options[intCounter].Label.LocalizedLabels[0].Label
                                    });

                                }
                            }
                            NotifyPropertyChanged("OptionSetItems");
                            RecordInformation = string.Format("1 - {0} of {0} (0 Selected)", _optionSetItems.Count);
                            IsBusy = false;
                        })
                    );
        }
]]&gt;
&lt;/script&gt;

&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 2&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
This is how you can get option set item using meta data request, if you want to get only string value of just one option set item then you can loop through the item in the option set and then use if condition to get the specific value and then break. You can use same request to get all option set item or you can get only one value of the option set item by passing the key ( integer value of the option set).&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Downloads&lt;/b&gt;&lt;br /&gt;
You can download the source code of the sample from &lt;a href="http://asimsajjad.googlecode.com/files/Account%20Grid%20V%201.0.8.zip"&gt;&lt;span style="color: #2181b7;"&gt;here&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;
and working CRM 2011 solution from &lt;a href="http://asimsajjad.googlecode.com/files/AccountGrid_1_0_8_0.zip"&gt;here&lt;/a&gt;. 

&lt;br /&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;
&lt;a href="http://asimsajjad.blogspot.com/2012/09/using-query-expression-in-silverlight.html" target="_blank"&gt;Go to Home&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;All 
and any comments / bugs / suggestions are welcomed!&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://asimsajjad.blogspot.com/2012/12/reading-optionset-items-keyvalue-using.html</link><author>noreply@blogger.com (Asim Sajjad)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg90ic8HVwalYq1cb8g7P2hTX9qJyzyvFtjYoVknUbxJ3lZWKuksmnrXZDaiIR2MjbLc0CqBzcBlWv_YpLIHDuipcCXz4xwIqPv8acuNPbyy26JBttivcKTAms8qCO-K-8yBLmegL7wl_s/s72-c/Default.png" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5765821788458763196.post-304652044982513343</guid><pubDate>Sun, 09 Dec 2012 09:02:00 +0000</pubDate><atom:updated>2012-12-09T14:02:36.008+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">MS CRM 2011</category><category domain="http://www.blogger.com/atom/ns#">SilverLight</category><title>Retrieve Entity Attributes Metadata</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Problem:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Need to get information regarding entity as well entity attributes.
&lt;/div&gt;
&lt;b&gt;Solution:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; As in my last &lt;a href="http://asimsajjad.blogspot.com/2012/11/retrieve-entities-metadata.html" target="_blank"&gt;post &lt;/a&gt;I have explain how to get meta data of the entities in the MS Dynamic CRM 2011, and get the information such as display name, schema name , description of the entities , now in this post I will explain how to get attributes information of each of the entity by providing entity name and then display the display name, schema name ,description and other properties of the attributes which an entity has.You can see the layout in &lt;i&gt;Image 1&lt;/i&gt;, here you can see that I have provided search box to enter name of the entity to search the attributes and then when user select entity name (as I have use auto complete box of Silverlight , I have also provide the entity names so that user can easily search name of the entity by entering some of the initial character of the entity name).Then in the data grid control I have display information of the attribute which an entity has.&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVevdfjglAeZs5bxThmswZ7dDxx9tn-g1lmhFt8TMGvm8Le0R3KiEUmRf5m1QJRsDlrJQF6iAo__bemeGMCAkwkVz-vH844a85qRUUBCghxPhh1uFJkdaSfKYrDXuHZ-OkykVIRKuKdZc/s1600/Default.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="224" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVevdfjglAeZs5bxThmswZ7dDxx9tn-g1lmhFt8TMGvm8Le0R3KiEUmRf5m1QJRsDlrJQF6iAo__bemeGMCAkwkVz-vH844a85qRUUBCghxPhh1uFJkdaSfKYrDXuHZ-OkykVIRKuKdZc/s400/Default.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 01&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Code to retrieve entity attribute meta data is listed in List 1, here you can see some of the difference of the code which I have used in my last &lt;a href="http://asimsajjad.blogspot.com/2012/11/retrieve-entities-metadata.html" target="_blank"&gt;post &lt;/a&gt;to get information of the entities.First thing which different is that request name here I have used the "RetrieveEntity" as request name, and then I have also mention the Attributes in the entity filter property of the request so that we can get attributes of the entity.Here you can see that in the Entity Filter attribute of the request I have mention both entity and attribute mean I want entity meta data and also attribute meta data of the entity which I am requesting.Next attribute of the request is the "LogicalName" , here I have provided schema name of the entity which user has selected from auto complete box.
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
&lt;![CDATA[
        public void getEntityMetadata() {
            try {
                _entityMetadatList.Clear();
                OrganizationRequest request = new OrganizationRequest() { RequestName = "RetrieveEntity" };
                request["EntityFilters"] = EntityFilters.Entity | EntityFilters.Attributes;
                request["RetrieveAsIfPublished"] = false;
                request["LogicalName"] = SelectedEntityName.SchemaName;
                request["MetadataId"] = Guid.Empty;
                BusyContent = string.Format("Loading {0} Entity Metadata Information...",SelectedEntityName.DisplayName);
                IOrganizationService service = SilverlightUtility.GetSoapService();

                service.BeginExecute(request, new AsyncCallback(getEntityMetadata_Callback), service);
                IsBusy = true;
            }
            catch (Exception Ex) {
                MessageText = string.Format("Error : {0}", Ex.Message);
            }
        }

        private void getEntityMetadata_Callback(IAsyncResult result) {
            Deployment.Current.Dispatcher.BeginInvoke
                    (
                        (() =&gt;
                        {
                            try {
                                OrganizationResponse response = ((IOrganizationService)result.AsyncState).EndExecute(result);
                                EntityMetadata entityMetadata = (EntityMetadata)response["EntityMetadata"];

                                foreach (AttributeMetadata attributeMetadata in entityMetadata.Attributes) {

                                    EntityMetadataRecord _entityMetadata = new EntityMetadataRecord();
                                    if ((attributeMetadata.IsCustomAttribute.Value == true) ||
                                        (attributeMetadata.IsCustomizable.Value == true)) {

                                        //get display name of entity.
                                        if (attributeMetadata.DisplayName.UserLocalizedLabel != null)
                                            _entityMetadata.DisplayName = attributeMetadata.DisplayName.UserLocalizedLabel.Label;
                                        else
                                            continue;
                                        //get logical name of entity.
                                        _entityMetadata.LogicalName = attributeMetadata.LogicalName;
                                        //    //get schema name of entity.
                                        _entityMetadata.SchemaName = attributeMetadata.SchemaName;
                                        //get object type code of entity.
                                        switch (attributeMetadata.AttributeType.Value.ToString().ToLower()) {
                                            case "string":
                                            _entityMetadata.Type = "Single Line of Text";
                                            break;
                                            case "uniquidentifie":
                                            _entityMetadata.Type = "Primary Key";
                                            break;
                                            case "picklist":
                                            _entityMetadata.Type = "Option Set";
                                            break;
                                            case "double":
                                            _entityMetadata.Type = "Floating Point Number";
                                            break;
                                            case "integer":
                                            _entityMetadata.Type = "Whole Number";
                                            break;
                                            case "money":
                                            _entityMetadata.Type = "Currency";
                                            break;
                                            case "boolean":
                                            _entityMetadata.Type = "Two Option";
                                            break;
                                            case "memo":
                                            _entityMetadata.Type = "Multiple Line of Text";
                                            break;
                                            case "datetime":
                                            _entityMetadata.Type = "Date and Time";
                                            break;
                                            default:
                                            _entityMetadata.Type = attributeMetadata.AttributeType.Value.ToString();
                                            break;
                                        }
                                        //decide whetehr entity is managed or unmanaged.
                                        _entityMetadata.IsManaged = attributeMetadata.IsManaged.Value == true ? "Managed" : "Unmanaged";
                                        //get IsCustomizable value of entity.
                                        _entityMetadata.IsCustomizable = attributeMetadata.IsCustomizable.Value;

                                        //    //get description of the entity.
                                        if (attributeMetadata.Description.UserLocalizedLabel != null)
                                            _entityMetadata.Description = attributeMetadata.Description.UserLocalizedLabel.Label;
                                        _entityMetadatList.Add(_entityMetadata);
                                    }
                                }
                                if (_entityMetadatList.Count == 0)
                                    MessageText = "There are no records in the system.";

                                RecordInformation = string.Format("1 - {0} of {0} (0 Selected)", _entityMetadatList.Count);
                                NotifyPropertyChanged("EntityMetadatList");
                            }
                            catch (Exception Ex) {
                                MessageText = string.Format("Error : {0}", Ex.Message);
                            }
                            IsBusy = false;
                        })
                    );
        }
]]&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 1&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Next is to send the request to retrieve the entity and entity attribute meta data , in the call back method I just loop through the attributes to get the properties like display name, schema name,  description etch of the attributes which will be displayed in the data grid control. In the call back method I have just used the proper type name for attribute type which are displayed in the entity customization.
&lt;/div&gt;
&lt;b&gt;Downloads&lt;/b&gt;&lt;br /&gt;
You can download the source code of the sample from &lt;a href="http://asimsajjad.googlecode.com/files/Account%20Grid%20V%201.0.7.zip"&gt;&lt;span style="color: #2181b7;"&gt;here&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;
and working CRM 2011 solution from &lt;a href="http://asimsajjad.googlecode.com/files/AccountGrid_1_0_7_0.zip"&gt;here&lt;/a&gt;. 

&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;
&lt;a href="http://asimsajjad.blogspot.com/2012/09/using-query-expression-in-silverlight.html" target="_blank"&gt;Go to Home&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;All 
and any comments / bugs / suggestions are welcomed!&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://asimsajjad.blogspot.com/2012/12/retrieve-entity-attributes-metadata.html</link><author>noreply@blogger.com (Asim Sajjad)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVevdfjglAeZs5bxThmswZ7dDxx9tn-g1lmhFt8TMGvm8Le0R3KiEUmRf5m1QJRsDlrJQF6iAo__bemeGMCAkwkVz-vH844a85qRUUBCghxPhh1uFJkdaSfKYrDXuHZ-OkykVIRKuKdZc/s72-c/Default.png" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5765821788458763196.post-4847420861668487654</guid><pubDate>Sat, 10 Nov 2012 05:45:00 +0000</pubDate><atom:updated>2012-11-10T10:45:25.830+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">MS CRM 2011</category><category domain="http://www.blogger.com/atom/ns#">SilverLight</category><title>Retrieve Entities Metadata </title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Problem:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Need to retrieve entities metadata information using Silverlight as web resource.
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Solution:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sometime you need to know about the entities in the MS CRM 2011 (mean in your organization). What are the properties of the entities such as the schema name, display name, logical name , whether the entity is managed or unmanaged, whether entity is used in the displayed in advance find or not, entity object type code like account has 1 and contact has 2 and so on.For this purpose I have created small application which will list some of the useful properties of the entities. You can see the output in the &lt;i&gt;Image 1&lt;/i&gt; here you can see that I have displayed the display name, name( logical name ), schema name , object type code, state ( where entity is managed or unmanaged), Customizable (Boolean type either true or false) and last one the description of the entity if it is provided.
&lt;/div&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj00QT0hHVRV2m3Oe0FytzThOxUhA6Tllz1XN6SEPuSbBmVenJxrZo6tNjJtYAD9S7P8Bot8WdcR5wLgGNmTGaybkDZpo1KXVHP1ESDqTkYfHAfZIm6uuWDyib33XZ1CIPyZII4c83gbrs/s1600/Default+Image.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="224" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj00QT0hHVRV2m3Oe0FytzThOxUhA6Tllz1XN6SEPuSbBmVenJxrZo6tNjJtYAD9S7P8Bot8WdcR5wLgGNmTGaybkDZpo1KXVHP1ESDqTkYfHAfZIm6uuWDyib33XZ1CIPyZII4c83gbrs/s400/Default+Image.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 1&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style="text-align: justify;"&gt;
Code is listed in &lt;i&gt;List 1&lt;/i&gt; , here you can see that I have used organization request object and pass the "RetrieveAllEntities" as request name. The "RetrieveAllEntities" request contains the data that is needed to retrieve metadata information about all the entities.Next is to set the "EntityFilters" attribute which take the one of the enumeration value of "EntityFilters".Here you can see that I have used the Entity which is also the default value if you don’t set the entity filter value and it is used to retrieve only entity information.Second and the last parameter which is set for the request object is the "RetrieveAsIfPublished" (Gets or sets whether to retrieve the metadata that has not been published) which take Boolean value and is required parameter. Here I have set it to false.Then created the service object and the used begin execute to past he request object, attached the callback function and also passed service object.&lt;br /&gt;
In the callback function you can see that first statement is to end the request which was execute request. And then get the entities from the response object here you can see that "EntityMetadata" is get from the response object.
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
&lt;![CDATA[
        public void getEntityMetadata() {
            try {
                EntityMetadatList.Clear();

                OrganizationRequest request = new OrganizationRequest() { RequestName = "RetrieveAllEntities" };
                request["EntityFilters"] = EntityFilters.Entity;
                request["RetrieveAsIfPublished"] = false;
                IOrganizationService service = SilverlightUtility.GetSoapService();

                service.BeginExecute(request, new AsyncCallback(getEntityMetadata_Callback), service);
                IsBusy = true;
            }
            catch (Exception Ex) {
                MessageText = string.Format("Error : {0}", Ex.Message);
            }
        }

        
        private void getEntityMetadata_Callback(IAsyncResult result) {
            try {
                OrganizationResponse response = ((IOrganizationService)result.AsyncState).EndExecute(result);
                ObservableCollection&lt;entitymetadata&gt; entities = (ObservableCollection&lt;entitymetadata&gt;)response["EntityMetadata"];

                ObservableCollection&lt;entitymetadatarecord&gt; _metadatList = new ObservableCollection&lt;entitymetadatarecord&gt;();
                foreach (EntityMetadata entity in entities) {
                    EntityMetadataRecord _entityMetadata = new EntityMetadataRecord();
                    if ((entity.IsCustomEntity.Value == true) ||
                        (entity.IsCustomizable.Value == true)) {

                        //get display name of entity.
                        if (entity.DisplayName.UserLocalizedLabel != null)
                            _entityMetadata.DisplayName = entity.DisplayName.UserLocalizedLabel.Label;
                        else
                            continue;
                        //get logical name of entity.
                        _entityMetadata.LogicalName = entity.LogicalName;
                        //get schema name of entity.
                        _entityMetadata.SchemaName = entity.SchemaName;
                        //get object type code of entity.
                        _entityMetadata.ObjectTypeCode = entity.ObjectTypeCode.Value;
                        //decide whetehr entity is managed or unmanaged.
                        _entityMetadata.IsManaged = entity.IsManaged.Value == true ? "Managed" : "Unmanaged";
                        //get IsCustomizable value of entity.
                        _entityMetadata.IsCustomizable = entity.IsCustomizable.Value;
                        
                        //get description of the entity.
                        if (entity.Description.UserLocalizedLabel != null)
                            _entityMetadata.Description = entity.Description.UserLocalizedLabel.Label;

                        _metadatList.Add(_entityMetadata);
                    }
                }
                if (_metadatList.Count == 0)
                    MessageText = "There are no records in the system.";
                else
                    EntityMetadatList = _metadatList;

                RecordInformation = string.Format("1 - {0} of {0} (0 Selected)", _metadatList.Count);
                NotifyPropertyChanged("EntityMetadatList");
            }
            catch (Exception Ex) {
                MessageText = string.Format("Error : {0}", Ex.Message);
            }
            IsBusy = false;
        }
]]&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 1&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Then I have used the foreach loop to loop through each entity and you can see that I have put if condition to filter the only those record which are either custom entity or is customizable. One more condition is check display name of the entity if it is null then continue don’t need to add entity which don’t have display name.And then used the entity properties which I want to display in the data grid control like, logical name, schema name, object type code, is managed, is customization and the description property. You can also use other properties which you want to display in the data grid control based on your requirement. Hope you get idea of how to get the entities metadata using the request object in Silverlight web resource.
&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Downloads&lt;/b&gt;&lt;br /&gt;
You can download the source code of the sample from &lt;a href="http://asimsajjad.googlecode.com/files/Account%20Grid%20V%201.0.6.zip"&gt;&lt;span style="color: #2181b7;"&gt;here&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;
and working CRM 2011 solution from &lt;a href="http://asimsajjad.googlecode.com/files/AccountGrid_1_0_6_0.zip"&gt;here&lt;/a&gt;. 

&lt;br /&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;
&lt;a href="http://asimsajjad.blogspot.com/2012/09/using-query-expression-in-silverlight.html" target="_blank"&gt;Go to Home&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;All 
and any comments / bugs / suggestions are welcomed!&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://asimsajjad.blogspot.com/2012/11/retrieve-entities-metadata.html</link><author>noreply@blogger.com (Asim Sajjad)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj00QT0hHVRV2m3Oe0FytzThOxUhA6Tllz1XN6SEPuSbBmVenJxrZo6tNjJtYAD9S7P8Bot8WdcR5wLgGNmTGaybkDZpo1KXVHP1ESDqTkYfHAfZIm6uuWDyib33XZ1CIPyZII4c83gbrs/s72-c/Default+Image.png" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5765821788458763196.post-6323774735146941962</guid><pubDate>Sun, 04 Nov 2012 05:28:00 +0000</pubDate><atom:updated>2012-11-04T10:28:57.625+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SilverLight</category><title>Using WrapPanel in Silverlight 4</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Problem:&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Need to use the WrapPanel control in Silverlight 4.
&lt;/div&gt;
&lt;b&gt;Solution:&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Like other layout control grid, stack panel or canvas etc are used to position control on specific order, in grid control you have to define the rows and columns and then set the row and column for the added control in the grid layout control, similarly you set the position of the control horizontal or vertical for the stack panel control and for the canvas you have to set the  top and left position of the control which you add in the canvas, but what if you want control to arranged according to the size they are given mean if you have size of 800 by 600 layout control and you have say 100 by 100 control added and want the control o fill the 800 by 600 layout control( like stack panel if you set  the orientation of the  stack panel to horizontal then control are arranged horizontally and if you set the  orientation to vertical then control are arranged in vertical direction but we want both if we have fix layout or resizable layout control). For this reason you can use the WrapPanel Control.&lt;br /&gt;
WrapPanel control will arranged child control first horizontally and if child controls are more than the width of the WrapPanel width then it will continue displaying control in new line and so on.  You can see the arrangement of the control in WrapPanel in &lt;i&gt;image 1&lt;/i&gt;. Here you can see that I have used the WrapPanel control to set the 2 column layout of child controls on left side of the user control and on right side I have used the image control to display the large image selected by user. I have also used the grid splitter control so that the size of the WrapPanel will be resized and you can see the arrangement of the control.
&lt;/div&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIeVBelcVTAwnmz9sTuPVfB8pa4kf9tK5tqMc6s9d9unUyV9msgQAy-lgMwKfg_K4p1h934Pvq_KVSOA_tNToqJmZ4xrZ3zyUyefWWpxQ3jafAS8Wm1v-LiU8ADVs5fdE_vTXH4a99S4A/s1600/Default+Image.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="255" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIeVBelcVTAwnmz9sTuPVfB8pa4kf9tK5tqMc6s9d9unUyV9msgQAy-lgMwKfg_K4p1h934Pvq_KVSOA_tNToqJmZ4xrZ3zyUyefWWpxQ3jafAS8Wm1v-LiU8ADVs5fdE_vTXH4a99S4A/s400/Default+Image.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 1&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
The xaml code for the list box control is listed in &lt;i&gt;list 1&lt;/i&gt;; here you can see that I have set the horizontal scrolling visibility of the list box control to disabled as I don’t want to have horizontal scrolling for my control only need vertical scrolling. Next in the list box xaml code you can see the I have define the Item template which include the image control to display image ( the width and height of the image control is set, I have set the width and height to 90 as I want to show thumbnail images) and the text block to display the image name.

&lt;script class="brush: xml" type="syntaxhighlighter"&gt;
&lt;![CDATA[
                    &lt;listbox x:Name="listBox"
                             Margin="0,5"
                             Background="{x:Null}"
                             ItemsSource="{Binding ImagesCollection}"
                             ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                             ScrollViewer.VerticalScrollBarVisibility="Auto"&gt;
                        &lt;ListBox.ItemTemplate&gt;
                            &lt;datatemplate&gt;
                                &lt;stackpanel Orientation="Vertical"&gt;
                                    &lt;image Width="90"
                                           Height="90"
                                           Source="{Binding ImageURL}" /&gt;
                                    &lt;textblock HorizontalAlignment="Center" Text="{Binding ImageName}" /&gt;
                                &lt;/StackPanel&gt;
                            &lt;/DataTemplate&gt;
                        &lt;/ListBox.ItemTemplate&gt;
                        &lt;ListBox.ItemsPanel&gt;
                            &lt;itemspaneltemplate&gt;
                                &lt;toolkit:WrapPanel&gt;
                                    &lt;i:Interaction.Behaviors&gt;
                                        &lt;ei:FluidMoveBehavior AppliesTo="Children"&gt;
                                            &lt;ei:FluidMoveBehavior.EaseY&gt;
                                                &lt;quarticease EasingMode="EaseOut" /&gt;
                                            &lt;/ei:FluidMoveBehavior.EaseY&gt;
                                            &lt;ei:FluidMoveBehavior.EaseX&gt;
                                                &lt;quarticease EasingMode="EaseIn" /&gt;
                                            &lt;/ei:FluidMoveBehavior.EaseX&gt;
                                        &lt;/ei:FluidMoveBehavior&gt;
                                    &lt;/i:Interaction.Behaviors&gt;
                                &lt;/toolkit:WrapPanel&gt;
                            &lt;/ItemsPanelTemplate&gt;
                        &lt;/ListBox.ItemsPanel&gt;
                    &lt;/ListBox&gt;
]]&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 1&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Next is the xaml code for the item panel template of the list box control, here you can see that I have added the wrap panel instead of using the stack panel control or any other layout control, also I have added the FluidMoveBehaviour which is provided by the expression blend (one of the built in behavior provided by the expression blend). And set the properties of the behavior like AppliedTo to "Children" and EaseX and EaseY properties animations. I have added the behavior as when you resize the WrapPanel width using the grid splitter provider between the list box control and the full size image control then you can see the rearrangement of the child controls.&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_LpU2vkge_iNfFcQkQ_5PNNPIgrGrOq6t4iGzHLSAt2nnwmsjWv7djVNlFGczceH78fNJ43h50P6oUv5NTutrRDTpza9aMH0WxpOp2ueAYA83oE9zRQuTrxeWvKPLuxnI2cAI7dtsWsA/s1600/Resized.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="210" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_LpU2vkge_iNfFcQkQ_5PNNPIgrGrOq6t4iGzHLSAt2nnwmsjWv7djVNlFGczceH78fNJ43h50P6oUv5NTutrRDTpza9aMH0WxpOp2ueAYA83oE9zRQuTrxeWvKPLuxnI2cAI7dtsWsA/s400/Resized.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 2&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style="text-align: justify;"&gt;
You can see the re-arrangement of the child control in Image 2. You can download the source code from &lt;a href="http://asimsajjad.googlecode.com/files/Thumbnail_View.zip" target="_blank"&gt;here&lt;/a&gt; and experience the re-arrangement of child control within the WrapPanel control.&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;All 
and any comments / bugs / suggestions are welcomed!&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt; &lt;/div&gt;
&lt;/div&gt;
</description><link>http://asimsajjad.blogspot.com/2012/11/using-wrappanel-in-silverlight-4.html</link><author>noreply@blogger.com (Asim Sajjad)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIeVBelcVTAwnmz9sTuPVfB8pa4kf9tK5tqMc6s9d9unUyV9msgQAy-lgMwKfg_K4p1h934Pvq_KVSOA_tNToqJmZ4xrZ3zyUyefWWpxQ3jafAS8Wm1v-LiU8ADVs5fdE_vTXH4a99S4A/s72-c/Default+Image.png" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5765821788458763196.post-7076136394315569385</guid><pubDate>Sun, 14 Oct 2012 02:35:00 +0000</pubDate><atom:updated>2012-10-20T13:44:54.924+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">MS CRM 2011</category><category domain="http://www.blogger.com/atom/ns#">SilverLight</category><title>Retrieve record by Using Many-To-Many Relation (Query Expression)</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Problem:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Need to retrieve related records by using many to many relations.
&lt;/div&gt;
&lt;b&gt;Solution:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;   As in MS Dynamics CRM there are 1:N (one- to-many  relation) , N:1 ( many- to- one relation) and there is N:N(many-to-many relation)  so some time you need to get data by using one of the above relation. Using either 1: N or N: 1 relation you can easily get the record of the related entity but using N: N many-to-many relation can be little tricky.So I will show you in this post how to used one of the many-to-many relation to get the related entity details if you have such type of requirements.&lt;br /&gt;
As I am working on account entity in this series of posts, I have used account and marketing list many-to-many relation.I have added another data grid control for this post as I will show all related market list for the selected account entity. You can see the main screen in &lt;i&gt;Image 1 &lt;/i&gt;, here the size of the marketing list data grid control will be less and I have just displayed the marketing list name, type(dynamic or static) and marketing list member type( the list is for account, contact or lead entity).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;b&gt;Note:&lt;/b&gt;For this post I have created separate view model for the marketing list data grid so that all the processing of the marketing list will be separated from the account data grid. You can find the new view model in the viewModel folder of the project with name “MarketingListViewModel”&amp;nbsp;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&lt;/i&gt;
&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSMmH4MA4_Y-B8Q4KmclhP-gUlSYaqZABulrogJTYC3qxQxTXMXiXA_OyLKzkD5TBPQzC_yS9_HXSsz0qut1amKHvJs-7eZCHqm9KpdjSxazA0DwVwMXDEmXYUfZRQswuI1qH0_cDeCRc/s1600/10-20-2012+7-59-52+AM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="141" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSMmH4MA4_Y-B8Q4KmclhP-gUlSYaqZABulrogJTYC3qxQxTXMXiXA_OyLKzkD5TBPQzC_yS9_HXSsz0qut1amKHvJs-7eZCHqm9KpdjSxazA0DwVwMXDEmXYUfZRQswuI1qH0_cDeCRc/s400/10-20-2012+7-59-52+AM.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 1&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Let us start with the code of how to retrieve using many-to-many relationship, the code is listed in the &lt;i&gt;List 1&lt;/i&gt;, which you can see as below. Here you can see that first I have set the name of the entity which is used to get the record and as you can see I have set the name of the entity which is used in the many-to-many relationship (I have pick name of the entity from the many-to-many relation dialog "Relationship Entity Name", I have also upload the image of the dialog and highlighted the "Relationship Entity Name" you can see it in &lt;i&gt;Image 2&lt;/i&gt;).Next thing is to add the condition to get the related record from the many-to-many entity; here I have passed the GUID of the account entity (entity which is selected by the user by clicking on the data grid row). So I will get all the records where account GUID will be matched( here I have set the attribute name to “entityid” which I have get by debugging the code by retrieving all the column with many-to-many entity name).

&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
&lt;![CDATA[
                QueryExpression _queryExpression = new QueryExpression();

                //set the entity name 
                _queryExpression.EntityName = "listmember";                

                //  Query using ConditionExpression
                ConditionExpression _entityIdCodeCondition = new ConditionExpression();
                _entityIdCodeCondition.AttributeName = "entityid";
                _entityIdCodeCondition.Operator = ConditionOperator.Equal;
                _entityIdCodeCondition.Values.Add(accountId);

                FilterExpression _filterExpression = new FilterExpression();
                _filterExpression.FilterOperator = LogicalOperator.And;
                _filterExpression.Conditions.Add(_entityIdCodeCondition);

                _queryExpression.Criteria = new FilterExpression();
                _queryExpression.Criteria.Filters.Add(_filterExpression);

                //link entity
                LinkEntity _marketingListEntity = new LinkEntity();
                _marketingListEntity.Columns = new ColumnSet();
                //columns of the related entity e.g marketing list name, type and member type
                _marketingListEntity.Columns.Columns = new ObservableCollection&lt;string&gt;(new string[] { MarketingListEntity.Type, MarketingListEntity.ListName, MarketingListEntity.MemberType });                
                //parent entity name. the many-to-many entity name
                _marketingListEntity.LinkFromEntityName = "listmember";
                //parent entity attribute name which will be linked
                _marketingListEntity.LinkFromAttributeName = MarketingListEntity.PrimaryId;
                //child entity name.
                _marketingListEntity.LinkToEntityName = MarketingListEntity.EntityName;
                //child entity attribute name which will be matched.
                _marketingListEntity.LinkToAttributeName = MarketingListEntity.PrimaryId;

                _marketingListEntity.EntityAlias = "marketingList";
                _queryExpression.LinkEntities = new ObservableCollection&lt;linkentity&gt;();
                _queryExpression.LinkEntities.Add(_marketingListEntity);]]&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 1&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Next is the link entity which I have also discussed in my post &lt;a href="http://asimsajjad.blogspot.com/2012/10/retrieving-child-entity-columns-using.html"&gt;"Retrieving Child Entity Columns Using Query Expression&lt;/a&gt;".here you can see that I have set the parent entity to the “Relationship entity name” as I will get ids of the list based on the entityid which is the id of the account records. So my parent entity will be the many-to-many entity name and then the parent entity attributes which will be mapped for the relationship is the id of the marketing list.After setting the parent entity name and the parent entity attribute next is to mention the child entity name and the child entity attribute, as I get to display the marketing list name and some of the information of the marketing list so my child entity will be marketing list as you can see that I have mention the LinkToEntityName and the LinkToAttributeName to marketing list name and marketing list id. Columns which I have retrieved for the linked entity are marketing list name, marketing list type (dynamic or static) and member type ( marketing list member type as marketing list is either for account , contact or lead entity).&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgm2a-11hkSqmfVKPjWpJROAhVpZZ1qKR47Y092Yllc7pf9FuQXI5AyY-JF0TueAC3hZP6PhI8E_zxr4nmgsNGfjDs3OxVMLn-KN2wjJO0d3ZWCahlhMe3eeA81uSH-AawSywRECsBG2RI/s1600/Many+to+many+name.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgm2a-11hkSqmfVKPjWpJROAhVpZZ1qKR47Y092Yllc7pf9FuQXI5AyY-JF0TueAC3hZP6PhI8E_zxr4nmgsNGfjDs3OxVMLn-KN2wjJO0d3ZWCahlhMe3eeA81uSH-AawSywRECsBG2RI/s400/Many+to+many+name.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 2&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Add the link entity to the query expression and then send the request to retrieve the record is there is any record for the account GUID which passed.&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Downloads&lt;/b&gt;&lt;br /&gt;
You can download the source code of the sample from &lt;a href="http://asimsajjad.googlecode.com/files/Account%20Grid%20V%201.0.5.zip"&gt;&lt;span style="color: #2181b7;"&gt;here&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;
and working CRM 2011 solution from &lt;a href="http://asimsajjad.googlecode.com/files/AccountGrid_1_0_5_0.zip"&gt;here&lt;/a&gt;. 

&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;
&lt;a href="http://asimsajjad.blogspot.com/2012/09/using-query-expression-in-silverlight.html" target="_blank"&gt;Go to Home&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;All 
and any comments / bugs / suggestions are welcomed!&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://asimsajjad.blogspot.com/2012/10/retrieve-record-by-using-many-to-many.html</link><author>noreply@blogger.com (Asim Sajjad)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSMmH4MA4_Y-B8Q4KmclhP-gUlSYaqZABulrogJTYC3qxQxTXMXiXA_OyLKzkD5TBPQzC_yS9_HXSsz0qut1amKHvJs-7eZCHqm9KpdjSxazA0DwVwMXDEmXYUfZRQswuI1qH0_cDeCRc/s72-c/10-20-2012+7-59-52+AM.png" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5765821788458763196.post-2777125642946821518</guid><pubDate>Mon, 08 Oct 2012 11:52:00 +0000</pubDate><atom:updated>2012-10-13T07:54:40.250+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">MS CRM 2011</category><category domain="http://www.blogger.com/atom/ns#">SilverLight</category><title>Retrieving Child Entity Columns Using Query Expression</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Problem:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Need to retrieve child entity attributes to be retrieved along the parent entity records. So that some of the child entity record should be displayed on the data grid.
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Solution:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; As the problem state that we are going to get some of child entity attribute so that we can display more detail of the child entity along the parent records. As in my previous posts regarding the query expressions I am using the “account” as main entity mean account will be my parent entity and the contact will be my child entity.For this post I have retrieve contact business phone and the parent account, I have also added two column in the data grid control to show the telephone and the parent account name ( for this post I have rearranged the columns so that primary contact information are side by side as can be seen in the &lt;i&gt;Image 1&lt;/i&gt;).&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0w1tQkV7JSRpDVKZ2QY9jfTyjLGkbDc2aL1ClqidRHfYj2u1pULzqZ6QiWIDv9SCZqMSH0JaksES6wGe_WJRQJwvApkOxWtvHCuCUva1rw43Ue_1pWGOQCQh1KKP9tpEGrpQIdW93OqQ/s1600/Image.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="224" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0w1tQkV7JSRpDVKZ2QY9jfTyjLGkbDc2aL1ClqidRHfYj2u1pULzqZ6QiWIDv9SCZqMSH0JaksES6wGe_WJRQJwvApkOxWtvHCuCUva1rw43Ue_1pWGOQCQh1KKP9tpEGrpQIdW93OqQ/s400/Image.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 1&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Let us start with the code which I have added for the link entity to be retrieved.Code is listed in&lt;i&gt; List 1&lt;/i&gt;, Here in code you can see that I have first created the LinkEntity object first and then I have set the column name which I want to get for the link entity (the child entity). Here you can see that I have used the “telephone1” and then “parentcustomerid”, these are the two attributes which will be displayed for the child entity as additional information for the child entity.&lt;br /&gt;
Next is how link the parent and child entity here you can see that link entity has properties like “LinkFromEntityName” which is used to get or set the logical name of the entity that you are linking from mean the parent entity (here “account is my parent entity).After setting the name of the parent entity next is to set name of the parent attribute which will be mapped to the child entity. Here you have to set the “LinkFromAttributeName” which is used to set the name of the parent entity attribute which will be mapped from. &lt;br /&gt;
Next is to set the “LinkToEntityName” which in my case is the “contact” entity, mean I want to link to the “contact” entity and then set the name of the attribute of the child entity in the “LinkToAttributeName” property. Here I have set the “contactid” as the mapped attribute in the child entity.Mean I want to map the “account” “primarycontactid” which is lookup to the contact entity to be mapped with the “contact” “contactid” so that I will get telephone1 and parentcustomerid of the contact which is the then lookup to the account entity.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
&lt;![CDATA[
                //link entity
                LinkEntity _contactLinkEntity = new LinkEntity();
                _contactLinkEntity.Columns = new ColumnSet();
                //columns of the related entity e.g telephone and the parent customer name.
                _contactLinkEntity.Columns.Columns = new ObservableCollection&lt;string&gt;(new string[] { "telephone1", "parentcustomerid" });
                //parent entity name.
                _contactLinkEntity.LinkFromEntityName = "account";
                //parent entity attribute name which will be linked
                _contactLinkEntity.LinkFromAttributeName = "primarycontactid";
                //child entity name.
                _contactLinkEntity.LinkToEntityName = "contact";
                //child entity attribute name which will be matched.
                _contactLinkEntity.LinkToAttributeName = "contactid";

                _contactLinkEntity.EntityAlias = "child";

                _queryExpression.LinkEntities = new ObservableCollection&lt;linkentity&gt;();
                _queryExpression.LinkEntities.Add(_contactLinkEntity);
]]&gt;
&lt;/script&gt;

&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 1&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Last property of the link entity object is to set the Alias of the entity which will then used to access the attribute values in the completed call back. Here I have set the “EntityAlias” to “child”.Then at the end just add the link entity object to the query expression “LinkEntities” collections.&lt;br /&gt;
After adding the link entity to the query expression next is how to get the value of the link entity attributes when call back function will be called. I have list only the piece of code which is used to get the values of the linked entity, which you can see in the &lt;i&gt;List 2&lt;/i&gt;.Here you can see that I have used the “AliasedValue” type to be getting using the GetAttibuteValue of entity and then converted to the respective type. For the phone number as it is of type string so I have used the value to convert to the Tostring. But for the EntityReference type (PrimaryAccount is of type entity reference) so the value is converted to EntityReferce type as you can see in &lt;i&gt;List 2&lt;/i&gt;.As “AliasedValue” is “Value is of “object” type so you have to convert it to respective type before using the using vaue.
 

&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
&lt;![CDATA[
                    accountRecord.PrimaryContactPhone = entity.GetAttributeValue&lt;aliasedvalue&gt;("child.telephone1").Value.ToString();

                    if (entity.GetAttributeValue&lt;aliasedvalue&gt;("child.parentcustomerid").Value != null) {
                        accountRecord.PrimaryAccount = entity.GetAttributeValue&lt;aliasedvalue&gt;("child.parentcustomerid").Value as EntityReference;
                        
                    }
]]&gt;
&lt;/script&gt;

&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 2&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Last piece of code is the xaml code which is used to bind the two new properties, telephone is simple string type so it will be easy to bind but the Primary account is of type EntityReference so we will use the Name property of “EntityReferece” for binding as you can see in the List 3. I have also appended “(Primary Contact)” with the header text of the columns so that you can distinguish between the attributes.
&lt;script class="brush: xml" type="syntaxhighlighter"&gt;
&lt;![CDATA[
                &lt;sdk:DataGridTextColumn MaxWidth="250"
                                        Binding="{Binding PrimaryAccount.Name}"
                                        Header="Primary Account (Primary Contact)"
                                        IsReadOnly="True" /&gt;
                &lt;sdk:DataGridTextColumn Binding="{Binding PrimaryContactPhone}"
                                        Header="Business Phone (Primary Contact)"
                                        IsReadOnly="True" /&gt;
]]&gt;
&lt;/script&gt;

&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 3&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
That is all about how to retrieve child entity attribute and mapped the linked attribute between parent and child entity. Hope you get starting point of how to use linked entity to get addition information regarding child entity.
&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Downloads&lt;/b&gt;&lt;br /&gt;
You can download the source code of the sample from &lt;a href="http://asimsajjad.googlecode.com/files/Account%20Grid%20V%201.0.4.zip"&gt;&lt;span style="color: #2181b7;"&gt;here&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;
and working CRM 2011 solution from &lt;a href="http://asimsajjad.googlecode.com/files/AccountGrid_1_0_4_0.zip"&gt;here&lt;/a&gt;. 
&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;
&lt;a href="http://asimsajjad.blogspot.com/2012/09/using-query-expression-in-silverlight.html" target="_blank"&gt;Go to Home&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;All 
and any comments / bugs / suggestions are welcomed!&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://asimsajjad.blogspot.com/2012/10/retrieving-child-entity-columns-using.html</link><author>noreply@blogger.com (Asim Sajjad)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0w1tQkV7JSRpDVKZ2QY9jfTyjLGkbDc2aL1ClqidRHfYj2u1pULzqZ6QiWIDv9SCZqMSH0JaksES6wGe_WJRQJwvApkOxWtvHCuCUva1rw43Ue_1pWGOQCQh1KKP9tpEGrpQIdW93OqQ/s72-c/Image.png" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5765821788458763196.post-7127360360648538976</guid><pubDate>Sun, 07 Oct 2012 11:52:00 +0000</pubDate><atom:updated>2012-10-13T07:54:52.441+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">MS CRM 2011</category><category domain="http://www.blogger.com/atom/ns#">SilverLight</category><title>Adding Conditions in Query Expression</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Problem: &lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In previous post related to the &lt;a href="http://asimsajjad.blogspot.com/2012/09/paging-data-using-query-expression.html" target="_blank"&gt;query expression&lt;/a&gt; I have added paging in query expression to get paged data, now need to add some condition so that we get the records based on some conditions. 
&lt;/div&gt;
&lt;b&gt;Solution: &lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; When working with data retrieval there are some condition based on which you have to fetched the records, if there is not client specific conditions then there must be at least one condition to get the active records.Image for the sample application is shown in &lt;i&gt;Image 1 &lt;/i&gt;as shown below, here you can see that I have displayed only the active records (I have deactivated the 3 records so that I have some active and deactivate records).&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFz3zwQk4nYqgyB31M0TpKkb4c0WXRcHzLNX9gocX4wjXyM6d06JOoSo0LwDx9krpNN-vZMxylyEChvl559oUhSqLXLFw634cpLFTvtfaMpNuNgIXPJUOpZRjyMAN7BQizPmRTT_A0Z28/s1600/9-30-2012+7-56-39+AM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFz3zwQk4nYqgyB31M0TpKkb4c0WXRcHzLNX9gocX4wjXyM6d06JOoSo0LwDx9krpNN-vZMxylyEChvl559oUhSqLXLFw634cpLFTvtfaMpNuNgIXPJUOpZRjyMAN7BQizPmRTT_A0Z28/s400/9-30-2012+7-56-39+AM.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 1&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;
The code for the sample which I have added is shown in the &lt;i&gt;List 1&lt;/i&gt; , here you can see that I have first created and initialized the condition expression object and then I have set the name of the attribute which I want to compare here I have mention the “statecode” mean I want to check the is record is active or not (you have to mention the schema name of the attribute here). Then next is the name of the operator which I will use for this condition and here you can see that I have used the ConditionOperator enumeration to select the operator which I will use for this condition and I have used equal operator. At the end is the values attribute which you need to set here as I have used equal operator so I will add just one value 0 ( mean I just want to get all the active records). You can add multiple values in the Values property the operator which may need more than one value are “in” operator or “between”  operator.&lt;br /&gt;
&lt;br /&gt;
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
&lt;![CDATA[
                //  Query using ConditionExpression
                ConditionExpression _stateCodeCondition = new ConditionExpression();
                _stateCodeCondition.AttributeName = "statecode";
                _stateCodeCondition.Operator = ConditionOperator.Equal;
                _stateCodeCondition.Values.Add(0);


                FilterExpression _filterExpression = new FilterExpression();
                _filterExpression.FilterOperator = LogicalOperator.And;
                _filterExpression.Conditions.Add(_stateCodeCondition);

                _queryExpression.Criteria = new FilterExpression();
                _queryExpression.Criteria.Filters.Add(_filterExpression);
]]&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 1&lt;/b&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Next is the filter expression object which is used to add the condition which we have created just above , the filter expression class has the filter operation which will be either “or” operator or “And” operation  I have used “And” operator mean no matter how many condition I will add to this filter expression object but we can just set one filter operator which will be applied on that condition if you want to set different filter operator then you have to create another filter operation object and add the condition in that filter expression object.After adding condition to the filter expression next is to add the filter expression to the query expression.&lt;br /&gt;
Hope you get an idea how to add condition to the query expression as conditions are the most important part of any query. You can add as many condition as you can but remember in one filter expression you can add only one filter operation which may be “Or” or “And” operation.Below are the links for the download for the source code and MS Crm 2011 solution.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Downloads&lt;/b&gt;&lt;br /&gt;
You can download the source code of the sample from &lt;a href="http://asimsajjad.googlecode.com/files/Account%20Grid%20V%201.0.3.zip"&gt;&lt;span style="color: #2181b7;"&gt;here&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;
and working CRM 2011 solution from &lt;a href="http://asimsajjad.googlecode.com/files/AccountGrid_1_0_3_0.zip"&gt;here&lt;/a&gt;. 
&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;
&lt;a href="http://asimsajjad.blogspot.com/2012/09/using-query-expression-in-silverlight.html" target="_blank"&gt;Go to Home&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;All 
and any comments / bugs / suggestions are welcomed!&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://asimsajjad.blogspot.com/2012/10/adding-conditions-in-query-expression.html</link><author>noreply@blogger.com (Asim Sajjad)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFz3zwQk4nYqgyB31M0TpKkb4c0WXRcHzLNX9gocX4wjXyM6d06JOoSo0LwDx9krpNN-vZMxylyEChvl559oUhSqLXLFw634cpLFTvtfaMpNuNgIXPJUOpZRjyMAN7BQizPmRTT_A0Z28/s72-c/9-30-2012+7-56-39+AM.png" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5765821788458763196.post-3002562277750680799</guid><pubDate>Tue, 25 Sep 2012 08:59:00 +0000</pubDate><atom:updated>2012-10-13T07:55:03.690+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">MS CRM 2011</category><category domain="http://www.blogger.com/atom/ns#">SilverLight</category><title>Paging Data Using Query Expression</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Problem:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In previous post related to the &lt;a href="http://asimsajjad.blogspot.com/2012/09/showing-busy-indicator-while-processing.html" target="_blank"&gt;query expression&lt;/a&gt; I have used simple query expression to get the records but now need to implement the paging by using the query expression. 
&lt;/div&gt;
&lt;b&gt;Solution:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Paging play very important role when you have large number of records. Say you have 1000 plus records or even 5000 plus records then it is better to page the data instead of showing  all the records at once as it will be very difficult for the user to search in the 1000 plus record and find the record which he/she is looking in the record set.You can see the main screen as shown in &lt;i&gt;Image 1&lt;/i&gt;, here you can see that I am shown the record information mean record start and end index like from 1 to 5 and then total number of record and the number of selected record at the bottom left of the grid( I have also attached note in the image as shown below) and then on the bottom right side I have display the current page number and then buttons for moving forward, backward and then to the first page( as there is no move to last page button in the MS CRM data grid so I have also not included that  button in my grid.&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgp_oSR3eyJTeE53NzeQwAkhRdswpPG5mGyGkwrx6EI2xTvrlu67CsSmLZTJoZAIxsYC4CkuAEIxCY5KJn-m5wZnpAqew8po1lFqsQwhBO2cXs6zywE2mrIKdMypOss0NiNoQxjgDYpbpo/s1600/Default.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgp_oSR3eyJTeE53NzeQwAkhRdswpPG5mGyGkwrx6EI2xTvrlu67CsSmLZTJoZAIxsYC4CkuAEIxCY5KJn-m5wZnpAqew8po1lFqsQwhBO2cXs6zywE2mrIKdMypOss0NiNoQxjgDYpbpo/s400/Default.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 1&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Let us now discuss the code needed for the paging in query expression. I have pasted only the related code for the paging as showing in &lt;i&gt;List 1&lt;/i&gt;, here you can see that instead of declaring the separate object of the PageInfo I have use the query expression PageInfo object and set the properties which I will used for paging.Here you can see that first property which I set for the PageInfo object is the PageNumber property , mean which page which want to retrieved for the very first time we will send 1 as the page number ( I have used local variable  to hold the current page number as page number will be changed from the backward, forward and first page buttons ). Second property which I set is the count property of the PageInfo object which is used to set the number of records per page which will be returned(I have set page size of 5 for my application you can set it to 25 or 50 whatever your requirement is).

&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
&lt;![CDATA[
                //set paging information.
                queryExpression.PageInfo = new PagingInfo();
                queryExpression.PageInfo.PageNumber = _pageNumber;
                queryExpression.PageInfo.Count = _pageSize;
                queryExpression.PageInfo.PagingCookie = _pagingCookie;
                queryExpression.PageInfo.ReturnTotalRecordCount = true;
]]&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 1&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Next property which I set is the PagingCookie, which is used for better performance when you use page and retrieve subsequent page. For the very first time query is send to retrieve the records the PagingCookie is set to null as no record is yet retrieved, when first call return it will contain the PagingCookie (the return PagingCookie is property of the EntityCollection object which you can save and then pass to the query expression if you want to move to next or previous page).The last property which I set for the PageInfo object is the ReturnTotalRecordCount property which is of type Boolean if you set it to true then it will return total number of records found for the criteria and if you set it to false then it will return -1 for total number of records for that criteria
&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
In the callback function I have also only pasted code which is needed for the paging, rest of the code is same, code is listed in &lt;i&gt;List 2&lt;/i&gt; as shown below. Here you can see that first I have get the MoreRecords property of the EntityCollection object, which is very important property. which indicate whether you have more records or not for the criteria you passed.Next property of the EntityCollection object is the TotalRecordCount, which I have stored in my local variable so that to show the total number of records found for the given criteria.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;b&gt;Note:&lt;/b&gt; if you have more than 5000 plus records for the entity from where you want to display data, then TotalRecordCount property will return 5000 count not more then 5000, that is why the property MoreRecords play important role mean it will indicate that you can still query from MS CRM for more records if your paging reach the 5000.As in your MS Crm data grid you can see the total count display 5000+ and you can still query for more records.&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&lt;/i&gt;
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
&lt;![CDATA[
                _hasMoreRecords = entityResults.MoreRecords;
                _totalRecordCount = entityResults.TotalRecordCount;

                if (entityResults.MoreRecords) {
                    _pagingCookie = entityResults.PagingCookie;
                }

]]&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 2&lt;/b&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Last property is the PagingCookie property of the EntityCollection object which is passed to the next query when send to retrieved the next or previous page records.&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;b&gt;Downloads&lt;/b&gt;&lt;br /&gt;
You can download the source code of the sample from &lt;a href="http://asimsajjad.googlecode.com/files/Account%20Grid%20V%201.0.2.zip"&gt;&lt;span style="color: #2181b7;"&gt;here&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;
and working CRM 2011 solution from &lt;a href="http://asimsajjad.googlecode.com/files/AccountGrid_1_0_2_0.zip"&gt;here&lt;/a&gt;. 
&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://asimsajjad.blogspot.com/2012/09/using-query-expression-in-silverlight.html" target="_blank"&gt;Go to Home&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;All 
and any comments / bugs / suggestions are welcomed!&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://asimsajjad.blogspot.com/2012/09/paging-data-using-query-expression.html</link><author>noreply@blogger.com (Asim Sajjad)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgp_oSR3eyJTeE53NzeQwAkhRdswpPG5mGyGkwrx6EI2xTvrlu67CsSmLZTJoZAIxsYC4CkuAEIxCY5KJn-m5wZnpAqew8po1lFqsQwhBO2cXs6zywE2mrIKdMypOss0NiNoQxjgDYpbpo/s72-c/Default.png" width="72"/><thr:total>4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5765821788458763196.post-5476222100145303445</guid><pubDate>Sun, 09 Sep 2012 07:51:00 +0000</pubDate><atom:updated>2012-10-13T07:55:16.911+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">MS CRM 2011</category><category domain="http://www.blogger.com/atom/ns#">SilverLight</category><title>Showing Busy Indicator while processing Background</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div dir="ltr" style="text-align: left;"&gt;
&lt;b&gt;Problem :&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-family: inherit;"&gt;In my last post “&lt;a href="http://asimsajjad.blogspot.com/2012/09/fetchretrieve-entity-using-query.html"&gt;Fetch/Retrieve Entity Using Query Expression&lt;/a&gt;” I have just added data grid control and on top right side on the data grid control was the refresh button which was not working, but in this post I will do some work so for refresh button and show busy indicator to the end users.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Solution :&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For this I have added the busy indicator control of the
silver light and used the one of the style which I have created for the silver
light &lt;a href="http://asimsajjad.blogspot.com/2012/03/microsoft-crm-2011-silverlight-busy.html" target="_blank"&gt;busy indicator&lt;/a&gt; control.I have placed in the Themes folder of the project with name “BusyIndicatorStyle.xaml” dictionary.I have used same approach which is used in the &lt;a href="http://www.devvblog.com/?p=58"&gt;post &lt;/a&gt;(from where I get the style of the data grid). Where he used the command to bind the refresh button so that we can perform action based on the command on the view model and command is bind in the data grid style and if you don’t have any command defined in your view model nothing will happened mean no error or exception is thrown. The delegate command class which is taken from original post of the data grid style is placed in the "Classes" folder of the project.You can see the busy indicator while fetching the records as shown in &lt;i&gt;Image 1&lt;/i&gt;.
&lt;/div&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-bSYoj301k_b2SAkvTXjebqyy9qtmIDT2JVoxyuE6dHp9EefqJeKLv63oDGwfj0O9eDS6vHKsVNUNi_kZYBy_dsfuLLh6Ft7iI1BRELMPRcX0fsQrQNnn6OaNaYg0rcETUCXlush1XdY/s1600/Loading+Accounts.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-bSYoj301k_b2SAkvTXjebqyy9qtmIDT2JVoxyuE6dHp9EefqJeKLv63oDGwfj0O9eDS6vHKsVNUNi_kZYBy_dsfuLLh6Ft7iI1BRELMPRcX0fsQrQNnn6OaNaYg0rcETUCXlush1XdY/s400/Loading+Accounts.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 1&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style="text-align: justify;"&gt;
Let us start with the code which I have added for the busy indicator mean the xaml and the properties which are added in the view model used to bind the is busy and busy content properties of the busy indicator control.In &lt;i&gt;List 1&lt;/i&gt; you can see I have pasted only  the xaml related to the busy indicator control, here you can see that I have bind the IsBusy and BusyContent of the busy indicator control which are the properties in the main view model class.
&lt;/div&gt;
&lt;script class="brush: xml" type="syntaxhighlighter"&gt;
&lt;![CDATA[
 &lt;toolkit:BusyIndicator Grid.RowSpan="2"
                               VerticalAlignment="Stretch"
                               BusyContent="{Binding BusyContent}"
                               IsBusy="{Binding IsBusy}" /&gt;
]]&gt;
&lt;/script&gt;

&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 1&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
In &lt;i&gt;List 2&lt;/i&gt; you can see that I have pasted the code which I have added for the busy indicator control and also the command of the “Refresh” button on the top right side of the data grid control. Here you can see the first property is the IsBusy of type Boolean which is bind with the IsBusy property of the busy indicator control as you can see in the &lt;i&gt;List 1&lt;/i&gt; (the xaml code for the busy indicator control). Here you can see the default value of the IsBusy property in the view model is false(when we send the async call to fetch the record which will set it to true which mean the busy indicator control will be shown and on call back function value is set to false mean busy indicator control will be hide).
&lt;/div&gt;
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
&lt;![CDATA[

        private Boolean _isBusy = false;
        public Boolean IsBusy {
            get { return _isBusy; }
            set {
                _isBusy = value;
                NotifyPropertyChanged("IsBusy");
            }
        }  
        
        string _busyContent = "Loading Account records...";
        public string BusyContent {
            get { return _busyContent; }
            set {
                _busyContent = value;
                NotifyPropertyChanged("BusyContent");
            }
        }

        public MainViewModel() {
            getAccountList();
            DataGridRefreshCommand = new DelegateCommand(DataGridRefresh, (x) =&gt; { return true; });
        }

        //Refresh command    
        public ICommand DataGridRefreshCommand { get; private set; }
        private void DataGridRefresh(object parameter) {
            BusyContent = "Refreshing Account List...";
            getAccountList();
        }

]]&gt;
&lt;/script&gt;

&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 2&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
The second property in the view model code as shown in the &lt;i&gt;List 2&lt;/i&gt; is the BusyContent property of type string which is bind with the BusyContent property to show the message to the user what is happening in the background. Default value of the BusyContent property is “Loading Account records…” and I have modified the message when we click the refresh button on the data grid control “Refreshing Account List...” is the message which will be shown to the user when he/she click the refresh button. Defining the property for the Busy content here is to show the message to user you can remove this property and hard code the message on the xaml end but as you have multiple operation on the view model so it is better to show different message based on operation.&lt;br /&gt;
The last is the command which is bind with the refresh button of the data grid control. Which is  taken from the original post and here I have added my code in the function to call the getAccountList function and before that statement I have changed the value of the BusyContent property to “Refresh Account List…”.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;b&gt;Note: &lt;/b&gt;The data grid style used in this example is taken from following &lt;a href="http://www.devvblog.com/?p=58"&gt;link&lt;/a&gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Downloads&lt;/b&gt;&lt;br /&gt;
You can download the source code of the sample from &lt;a href="http://asimsajjad.googlecode.com/files/Account%20Grid%20V%201.0.1.zip"&gt;&lt;span style="color: #2181b7;"&gt;here&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;
and working CRM 2011 solution from &lt;a href="http://asimsajjad.googlecode.com/files/AccountGrid_1_0_1_0.zip"&gt;here&lt;/a&gt;. 
&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://asimsajjad.blogspot.com/2012/09/using-query-expression-in-silverlight.html" target="_blank"&gt;Go to Home&lt;/a&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;All 
and any comments / bugs / suggestions are welcomed!&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://asimsajjad.blogspot.com/2012/09/showing-busy-indicator-while-processing.html</link><author>noreply@blogger.com (Asim Sajjad)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-bSYoj301k_b2SAkvTXjebqyy9qtmIDT2JVoxyuE6dHp9EefqJeKLv63oDGwfj0O9eDS6vHKsVNUNi_kZYBy_dsfuLLh6Ft7iI1BRELMPRcX0fsQrQNnn6OaNaYg0rcETUCXlush1XdY/s72-c/Loading+Accounts.png" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5765821788458763196.post-6258648732034846897</guid><pubDate>Sat, 08 Sep 2012 08:57:00 +0000</pubDate><atom:updated>2012-10-13T07:54:02.211+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">MS CRM 2011</category><category domain="http://www.blogger.com/atom/ns#">SilverLight</category><title>Fetch/Retrieve Entity Using Query Expression</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Problem :&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Need to fetch/retrieve the entity record using the query expression.&lt;/div&gt;
&lt;/div&gt;
&lt;b&gt;Solution:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I have spend lot of time in fetching the different entities record and now I  got some time to share this learning with all of you so that if anyone of you who is beginner and want to learn the fetch/retrieve of the entity record then he/she will learn something from here. I know there are lot of post available on internet but I want to share what I have learn with easy words so that you people can understand it easily.&lt;br /&gt;
I have used the Silver light web resource for this mean to fetch/retrieve the entity record and I have used the SOAP endpoint to fetch/retrieve the entity record. For you learning if you don’t have idea how to used the fetch end points in your web resource like Silver light  then you can read the following article by the &lt;a href="http://msdn.microsoft.com/en-us/library/gg594452"&gt;CRM 2011 SDK&lt;/a&gt;. Here you will learn what initial steps are need to add the SOAP endpoint and it will also give some introduction to the two classes which SOAP endpoint will use and what changes you need to do in the Reference.cs file.
&lt;br /&gt;
Let us start the example code which is used to fetch the entity records. Here I have used the account entity to display data without any condition, all accounts record are fetched and displayed in the grid and you can see the output in the &lt;i&gt;Image 1&lt;/i&gt; as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUC9YUfuw4Eysdh9i357K6PyOCLFQjVONcGFjQOnMrgYBiUwgQ77CvwqMb5_Go-HUo_ZtWOHCW89V5McGXkLfwuiuEZKQnszbmSgfuWv5aygmz_nSul5JbFNjqDo4YHNNn-NPLHMieT0Y/s1600/Account+Grid+Main.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUC9YUfuw4Eysdh9i357K6PyOCLFQjVONcGFjQOnMrgYBiUwgQ77CvwqMb5_Go-HUo_ZtWOHCW89V5McGXkLfwuiuEZKQnszbmSgfuWv5aygmz_nSul5JbFNjqDo4YHNNn-NPLHMieT0Y/s400/Account+Grid+Main.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 1&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
In &lt;i&gt;Image 1&lt;/i&gt; you can see that I have used the data grid control of the Silver light to show the account entity record which contains the Account Name, Main Phone, Primary Contact, Email and Account number attributes of the accounts.I have used the MVVM approach to bind the data grid control of the Silver light, so all of my code will be in the view model of which is named MainViewModel and is placed in the ViewModel folder.&lt;br /&gt;
Code to fetch the account entity record is shown in &lt;i&gt;List 1&lt;/i&gt;; here you can see that I have used the queryExpression class to retrieve the account entity.Here you can see that after declaring and initialization of the query expression object I have set the name of the entity in the second statement ( I have used the account entity and you can changed it whatever your entity name like contact, lead etc).Next is to set the which attributes need to be fetched from the account entity, for this you can used the Column set property of the query expression and give an array of string which contain the schema name of the attributes . Here you can see that I have used the accountid, name, statecode, statuscode, primarycontactid, accountnumber, emailaddress1, telephone1, address1_shippingmethodcode attributes name to be fetched.&lt;br /&gt;
If you want that your return records are in specific order by some attribute name then you can use the order property of the query expression and give the attribute name by which you want your record to be ordered. Here I have used the name attribute of the account so that my records are order by account name Ascending &lt;/div&gt;
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
&lt;![CDATA[
        public void getAccountList() {
            try
            {
                QueryExpression queryExpression = new QueryExpression();
               
                //set the entity name 
                queryExpression.EntityName = "account";

                //add the attribute name which are used to fetch from the entity name.
                queryExpression.ColumnSet = new ColumnSet();
                queryExpression.ColumnSet.Columns = new ObservableCollection&lt;string&gt;(new string[] { "accountid", "name", "statecode", "statuscode", "primarycontactid", "accountnumber", "emailaddress1", "telephone1", "address1_shippingmethodcode" });

                //set the order by expression, here order by expression used name to order the end result.
                OrderExpression orderByName=new OrderExpression() { AttributeName = "name", OrderType = OrderType.Ascending };
                queryExpression.Orders=new ObservableCollection&lt;orderexpression&gt;();
                queryExpression.Orders.Add(orderByName);

                OrganizationRequest organizationRequest= new OrganizationRequest() { RequestName = "RetrieveMultiple" };
                organizationRequest["Query"] = queryExpression;

                IOrganizationService organizationService= SilverlightUtility.GetSoapService();
                organizationService.BeginExecute(organizationRequest, new AsyncCallback(AccountList_ClickCallback), organizationService);
            }
            catch (Exception Ex)
            {
                MessageText = string.Format("Error : {0}", Ex.Message);
            }
        }

        private void AccountList_ClickCallback(IAsyncResult result) {
            try
            {
                OrganizationResponse organizationResponse = ((IOrganizationService)result.AsyncState).EndExecute(result);
                EntityCollection entityResults = (EntityCollection)organizationResponse["EntityCollection"];

                if (entityResults.Entities.Count == 0)
                    MessageText = "There are no Account records in the system.";
                ObservableCollection&lt;accounts&gt; accountList = new ObservableCollection&lt;accounts&gt;();
                foreach (Entity entity in entityResults.Entities)
                {
                    Accounts accountRecord = new Accounts();
                    accountRecord.AccountId = entity.Id;
                    accountRecord.AccountName = entity.GetAttributeValue&lt;string&gt;("name");
                    accountRecord.StateCode = entity.GetAttributeValue&lt;optionsetvalue&gt;("statecode").Value;
                    accountRecord.StatusCode = entity.GetAttributeValue&lt;optionsetvalue&gt;("statuscode").Value;
                    if (entity.GetAttributeValue&lt;entityreference&gt;("primarycontactid") != null)
                    {
                        accountRecord.PrimaryContactName = entity.GetAttributeValue&lt;entityreference&gt;("primarycontactid").Name;
                        accountRecord.PrimaryContactId = entity.GetAttributeValue&lt;entityreference&gt;("primarycontactid").Id;
                    }
                    accountRecord.AccountNumber = entity.GetAttributeValue&lt;string&gt;("accountnumber");
                    accountRecord.EmailAddress = entity.GetAttributeValue&lt;string&gt;("emailaddress1");
                    accountRecord.MainTelephone = entity.GetAttributeValue&lt;string&gt;("telephone1");
                    if (entity.GetAttributeValue&lt;optionsetvalue&gt;("address1_shippingmethodcode") != null)
                        accountRecord.Address1_ShippingMethodCode = entity.GetAttributeValue&lt;optionsetvalue&gt;("address1_shippingmethodcode").Value;
                    accountList.Add(accountRecord);
                }
                AccountList = accountList;
                MessageText = "Accounts retrieved successfully.";
                
            }
            catch (Exception Ex)
            {
                MessageText = string.Format("Error : {0}", Ex.Message);
            }
        }
]]&gt;
&lt;/script&gt;

&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 1&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
After setting all the required properties of the query expression next is to create the Organization service object to send the query expression and retrieve the entity records. Here you can see in the constructor of the Organization service I have passed the request name “RetrieveMultiple“ as I am retrieving not single records as I didn’t add any condition in the query expression to get only specific record.For complete list of request name you can check the following &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.xrm.sdk.organizationrequest.requestname.aspx"&gt;link&lt;/a&gt;.Next is to create the IOrganizationService object and then pass the request and the call back function name and the addition data which you need on the call back function.&lt;br /&gt;
In the call back function first statement is to end the request which was send and store the return object in the OrganizationResponse which is return by the EndExcute function(as we used BeginExecute of the IOrganizationService so we need to call the end of function which we are calling if you call BeginRetrieveMultiple then you need to call EndRetrieveMultiple in the call back function).Then by using the Organization response object need to get the EntityCollection and store it in the EntityCollection object for further manipulation as we need to display the attribute value in the data grid. After storing the EntityCollection in EntityCollection object next is to check the count of the records if no record then display message else use the foreach loop to create the collection which is bind to the data grid control to display account entity records. Here you can see that I have used the GetAttributeValue of the extension method to get the value of the specific attribute.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;i&gt;&lt;b&gt;Note: &lt;/b&gt;The data grid style used in this example is taken from following &lt;a href="http://www.devvblog.com/?p=58"&gt;link&lt;/a&gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Downloads&lt;/b&gt;&lt;br /&gt;
You can download the source code of the sample from &lt;a href="http://asimsajjad.googlecode.com/files/Account%20Grid.zip"&gt;&lt;span style="color: #2181b7;"&gt;here&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;
and working CRM 2011 solution from &lt;a href="http://asimsajjad.googlecode.com/files/AccountGrid_1_0_0_0.zip"&gt;here&lt;/a&gt;. &lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://asimsajjad.blogspot.com/2012/09/using-query-expression-in-silverlight.html" target="_blank"&gt;Go to Home&lt;/a&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;All 
and any comments / bugs / suggestions are welcomed!&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&amp;nbsp;
&lt;/div&gt;
</description><link>http://asimsajjad.blogspot.com/2012/09/fetchretrieve-entity-using-query.html</link><author>noreply@blogger.com (Asim Sajjad)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUC9YUfuw4Eysdh9i357K6PyOCLFQjVONcGFjQOnMrgYBiUwgQ77CvwqMb5_Go-HUo_ZtWOHCW89V5McGXkLfwuiuEZKQnszbmSgfuWv5aygmz_nSul5JbFNjqDo4YHNNn-NPLHMieT0Y/s72-c/Account+Grid+Main.png" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5765821788458763196.post-7483997312068848700</guid><pubDate>Fri, 07 Sep 2012 02:31:00 +0000</pubDate><atom:updated>2013-01-25T08:44:57.249+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">MS CRM 2011</category><title>Using Query Expression in Silverlight Web Resource</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div style="text-align: justify;"&gt;
During my work on MS CRM 2011 I have most of my work is on Silverlight web resource and here in this post I will list how to use the query expression in your Silverlight web resource. This will be series of article which will explain difference scenarios regarding question expression.First I will start with basic of the query expression and will guide you how to add create CRM grid in Silverlight web resource.&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="http://asimsajjad.blogspot.com/2012/09/fetchretrieve-entity-using-query.html" target="_blank"&gt;Fetch/Retrieve Entity Using Query Expression&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://asimsajjad.blogspot.com/2012/09/showing-busy-indicator-while-processing.html" target="_blank"&gt;Showing Busy Indicator while processing Background&amp;nbsp;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://asimsajjad.blogspot.com/2012/09/paging-data-using-query-expression.html" target="_blank"&gt;Paging Data Using Query Expression&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://asimsajjad.blogspot.com/2012/10/adding-conditions-in-query-expression.html" target="_blank"&gt;Adding Conditions in Query Expression&lt;/a&gt;
&amp;nbsp;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://asimsajjad.blogspot.com/2012/10/retrieving-child-entity-columns-using.html" target="_blank"&gt;Retrieving Child Entity Columns Using Query Expression&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://asimsajjad.blogspot.com/2012/10/retrieve-record-by-using-many-to-many.html" target="_blank"&gt;Retrieve record by Using Many-To-Many Relation (Query Expression)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://asimsajjad.blogspot.com/2012/12/reading-user-settings-by-user-id.html" target="_blank"&gt;Reading User Settings by User Id &lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://asimsajjad.blogspot.com/2012/12/reading-organization-setting.html" target="_blank"&gt;Reading Organization Settings&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
I will keep update this post as I write new post related to the query expression.&lt;br /&gt;
&lt;br /&gt;
Metadata retrieval &lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="http://asimsajjad.blogspot.com/2012/11/retrieve-entities-metadata.html" target="_blank"&gt;Retrieving Entity Metadata&lt;/a&gt;&amp;nbsp; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://asimsajjad.blogspot.com/2012/12/retrieve-entity-attributes-metadata.html" target="_blank"&gt;Retrieving Entity Attribute Metadata&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://asimsajjad.blogspot.com/2012/12/reading-optionset-items-keyvalue-using.html" target="_blank"&gt;Reading OptionSet Items Key/value Using MetaData Request &lt;/a&gt;&amp;nbsp;&amp;nbsp; &lt;/li&gt;
&lt;/ol&gt;
&lt;i&gt;&lt;b&gt;Note: &lt;/b&gt;The data grid style used in this example is taken from following &lt;a href="http://www.devvblog.com/?p=58"&gt;link&lt;/a&gt;&lt;/i&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;All 
and any comments / bugs / suggestions are welcomed!&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;</description><link>http://asimsajjad.blogspot.com/2012/09/using-query-expression-in-silverlight.html</link><author>noreply@blogger.com (Asim Sajjad)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5765821788458763196.post-4286258334047742056</guid><pubDate>Sat, 04 Aug 2012 10:41:00 +0000</pubDate><atom:updated>2012-08-04T15:41:43.298+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SilverLight</category><title>Best Way to Use PagedCollectionView With Datagrid Control</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Problem :&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I have used Paged Collection view whenever I need to create application which has data grid control to display the item in tabular format. I used to new collection every time I get data and then create new Paged collection view. In this post I will show you how to use one collection and update it. Which I think is best practice to use the Paged collection view with data grid control.&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Solution :&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Let us start with the example code, First you can see the Image of the sample example which I have used for this post as you can see in &lt;i&gt;Image 1&lt;/i&gt;, here you can see that I have serial number, First name, Last name and the Address fields which user can input and then Save button which is used to add the user input into the data grid.
&lt;/div&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4ZUKLYB1-geE2uY_IkqTLBH6qrp9YccDkLCuWMuck7WwL5fm6Xp4i2zzo7J7jbkrv6MVfa-Y68VH8biDwCqtP6z7S1nM9UqGfQdSvhwipHb75towEu8zXALgmTuBJHmiUF8cB27Rq1Ss/s1600/Default.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="284" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4ZUKLYB1-geE2uY_IkqTLBH6qrp9YccDkLCuWMuck7WwL5fm6Xp4i2zzo7J7jbkrv6MVfa-Y68VH8biDwCqtP6z7S1nM9UqGfQdSvhwipHb75towEu8zXALgmTuBJHmiUF8cB27Rq1Ss/s400/Default.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 1&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style="text-align: justify;"&gt;
Next is the view model of the view which I have placed in the viewModel folder, here you can see that I have create property which are used in the view model and my view model is not inherited from the INotifyPropertyChanged interface as the PagedCollectionView is inherited from INotifyPropertyChanged interface.&lt;br /&gt;
First I have the Customer new record property which is of type Customer ( Customer is my class which is placed in the class folder and has the serial number, first name , last name and the address property and also inherited from the INotifyPropertyChanged interface , and also have function to get the first few record which are displayed in the data grid when you run the application.)Next is the list of customer which will hold the customer list and it is private collection which is used locally by the view model class. After the customer list which is of customer type is the Paged Collection view of the customer records which are actually bind with the data grid control (CustomerRecords is the name of the variable of type PagedCollectionView)
&lt;/div&gt;
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
&lt;![CDATA[
public class HomeViewModel  {

        Customer _customerNewRecord = new Customer();
        public Customer CustomerNewRecord {
            get { return _customerNewRecord; }
            set { _customerNewRecord = value; }
        }


        private ObservableCollection&lt;customer&gt; _customerList = null;
        public PagedCollectionView CustomerRecords { get; set; }


        public HomeViewModel() {
            _customerList = new ObservableCollection&lt;customer&gt;();
            CustomerRecords = new PagedCollectionView(_customerList);
            CustomerRecords.SortDescriptions.Add(new SortDescription("SerialNumber", ListSortDirection.Descending));
            Customer.getCustomerRecords(_customerList);
        }

     
        public void SaveRecord() {
            _customerList.Add(new Customer() { SerialNumber = CustomerNewRecord.SerialNumber, FirstName = CustomerNewRecord.FirstName, LastName = CustomerNewRecord.LastName, Address = CustomerNewRecord.Address });
        }            
    }    
]]&gt;
&lt;/script&gt;
&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 1&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Next is the constructor of the view model which is used to initialize the data member and the customer list collection. Here you can see first I have initiated the customer list collection and then the pagedCollectionview object and also the sort description the paged collection view object and then at the end added some records in the customer list collection so that you can see some records in the data grid when application loaded.At the end is the function to add the new record which user enter to the customer list ( customer  list is of type customer which has the serial number, first name , last name and the Address properties which are bind to the text box control on the view respectively). When ever used enter new record and press save button new record will be added in the data grid control without raising the notification to the view as my view model is not inherited from the INotifyPropertyChanged interface.&lt;br /&gt;
&lt;br /&gt;
By using this technique you can just initialize the Paged collection view object just one and also the added the sort description just once, no need to re-initialize the page collection view object every time you get data from data base or some source like I have mention I was doing in my project just clear the observable collection object and add the record in that collection and the records are displayed on the data grid control as the Paged collection view is inherited from INotifyPropertyChanged interface.You can download the source code of the sample from &lt;a href="http://asimsajjad.googlecode.com/files/Best_Way_To_Use_Collection_With_Datagrid.zip"&gt;&lt;span style="color: #2181b7;"&gt;here&lt;/span&gt;&lt;/a&gt;. 

&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;All 
and any comments / bugs / suggestions are welcomed!&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</description><link>http://asimsajjad.blogspot.com/2012/08/best-way-to-use-pagedcollectionview.html</link><author>noreply@blogger.com (Asim Sajjad)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4ZUKLYB1-geE2uY_IkqTLBH6qrp9YccDkLCuWMuck7WwL5fm6Xp4i2zzo7J7jbkrv6MVfa-Y68VH8biDwCqtP6z7S1nM9UqGfQdSvhwipHb75towEu8zXALgmTuBJHmiUF8cB27Rq1Ss/s72-c/Default.png" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5765821788458763196.post-7976313512649097845</guid><pubDate>Fri, 16 Mar 2012 12:08:00 +0000</pubDate><atom:updated>2012-06-18T19:46:13.855+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SilverLight</category><title>RadioButton List Using Silverlight</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Problem:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Need to create radio button list so that user can select one option from the given list of the collections.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;Solution:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The solution to the above problem is very simple if you read my last &lt;a href="http://asimsajjad.blogspot.com/2012/03/simple-way-to-create-checkbox-list-in.html" target="_blank"&gt;post &lt;/a&gt;how to create checkbox list control. We will use similar approach as we have used in the create checkbox list control. You can see the output in the &lt;i&gt;Image 1&lt;/i&gt; as shown below, here you can see that I have list of customer from where user can select one of the customers and the selected customer is displayed at the end of the list.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3_KPtv8bFvv5QVPIPxQyICXXeTLH7HaHHSKVSwI8U41OI-XcfDHWcZ33o_f_1m31gCTbRxGkslVathVPZX8k-ISf_57cUcF1-Ur1XHJY2tVSQHvRdSByXN4qbbpZWut3AY1_hx18y_1g/s1600/Image+1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3_KPtv8bFvv5QVPIPxQyICXXeTLH7HaHHSKVSwI8U41OI-XcfDHWcZ33o_f_1m31gCTbRxGkslVathVPZX8k-ISf_57cUcF1-Ur1XHJY2tVSQHvRdSByXN4qbbpZWut3AY1_hx18y_1g/s400/Image+1.png" width="382" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 1&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;
The xaml code for creating the radio button list is similar to the checkbox list but what we need to replace the checkbox control with the radio button control (as in case of radio button we know that radio button is used to select only one option from the group of radio button so we don’t need to have the All option (for selecting all the options) which we created for the checkbox list). So in the List 1 you can see only the Item control which contains the radio buttons in its item template so that we have the radio button list for the user to select the option.&lt;/div&gt;
&lt;script class="brush: xml" type="syntaxhighlighter"&gt;
&lt;![CDATA[
                &lt;itemscontrol Margin="5" ItemsSource="{Binding CustomerList}"&gt;
                    &lt;ItemsControl.ItemsPanel&gt;
                        &lt;itemspaneltemplate&gt;
                            &lt;stackpanel Orientation="Vertical" /&gt;
                        &lt;/ItemsPanelTemplate&gt;
                    &lt;/ItemsControl.ItemsPanel&gt;
                    &lt;ItemsControl.ItemTemplate&gt;
                        &lt;datatemplate&gt;
                            &lt;radiobutton Margin="5"
                                         ClickMode="Press"
                                         IsChecked="{Binding IsSelected,
                                                             Mode=TwoWay}"&gt;
                                &lt;RadioButton.Content&gt;
                                    &lt;textblock&gt;
                                        &lt;run Text="{Binding FirstName}" /&gt;
                                        &lt;run Text="{Binding LastName}" /&gt;
                                    &lt;/TextBlock&gt;
                                &lt;/RadioButton.Content&gt;
                            &lt;/RadioButton&gt;
                        &lt;/DataTemplate&gt;
                    &lt;/ItemsControl.ItemTemplate&gt;
                &lt;/ItemsControl&gt;
                &lt;textblock Margin="5"&gt;
                    &lt;run Text="Selected Value: " /&gt;
                    &lt;run Text="{Binding Path=SelectedValue, Mode=OneWay}" /&gt;
                &lt;/TextBlock&gt;]]&gt;
&lt;/script&gt;
&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 1&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
There is not much in the home view model (view model for the home view, views are located in the view folder and view models are located in the viewModel folder). Just based on the property changed event for the particular radio button I just display the serial number and the full name of the record which is currently selected by the user.
You can download the source code of the sample from &lt;a href="http://asimsajjad.googlecode.com/files/RadioButton_List_Control.zip"&gt;&lt;span style="color: #2181b7;"&gt;here&lt;/span&gt;&lt;/a&gt;. 
&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;All 
and any comments / bugs / suggestions are welcomed!&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;</description><link>http://asimsajjad.blogspot.com/2012/03/radiobutton-list-using-silverlight.html</link><author>noreply@blogger.com (Asim Sajjad)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3_KPtv8bFvv5QVPIPxQyICXXeTLH7HaHHSKVSwI8U41OI-XcfDHWcZ33o_f_1m31gCTbRxGkslVathVPZX8k-ISf_57cUcF1-Ur1XHJY2tVSQHvRdSByXN4qbbpZWut3AY1_hx18y_1g/s72-c/Image+1.png" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5765821788458763196.post-4512483920151771757</guid><pubDate>Fri, 16 Mar 2012 06:54:00 +0000</pubDate><atom:updated>2012-06-14T12:06:29.898+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SilverLight</category><title>Simple Way To Create CheckBox List In Silverlight</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Problem&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; We have a requirement to create the Checkbox list control so that user can select multiple options from a given list for his/her choice.&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Solution&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Solution to above problem is very simple if you read my post "&lt;a href="http://asimsajjad.blogspot.com/2012/03/silverlight-itemcontrol-for-beginners.html" target="_blank"&gt;Silverlight ItemControl For Beginners&lt;/a&gt;" where I have explained how to use the item control in Silver light and why item control is used.To create Checkbox list control we will use same item control as it don’t have the selected item and mouse over behavior which we don’t need for the Checkbox list control.You can see the output in the &lt;em&gt;Image 1&lt;/em&gt; as shown, here you can see that I have also &lt;b&gt;All&lt;/b&gt; option and then list of the customer name as Checkbox list so that user can select one or more customer from the list or he/she can select all by using the &lt;b&gt;All &lt;/b&gt;option.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg15yvsMC5HtPj6yDNdwBfCN4Zl6_1vjaQYT0BxgQgXyZ27g7ULCJc-Edx5LGVf5dyWdk50q2T1EmKmFbRWuiHL2jvMSGmtPLhONCKHIzgk2fuO0xYa5cXZubGaYQzRj3yD_3kmNT8OU2M/s1600/6-13-2012+8-25-04+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg15yvsMC5HtPj6yDNdwBfCN4Zl6_1vjaQYT0BxgQgXyZ27g7ULCJc-Edx5LGVf5dyWdk50q2T1EmKmFbRWuiHL2jvMSGmtPLhONCKHIzgk2fuO0xYa5cXZubGaYQzRj3yD_3kmNT8OU2M/s400/6-13-2012+8-25-04+PM.png" width="307" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 1&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
In Image you can see that some of the customers are checked and some are not and by default the &lt;strong&gt;All&lt;/strong&gt; option is not checked.&lt;br /&gt;
Let us start with the xaml code first mean how we created the checkbox list for the users so that he/she can select one or more customer from the given list of customers.The xaml code for the checkbox list is listed in&lt;em&gt; List 1&lt;/em&gt; here you can see that I have first inserted the check box control for the &lt;strong&gt;All&lt;/strong&gt; option which is used to checked or un-checked all check box control depending on the value of the All check box checked property.The &lt;b&gt;All &lt;/b&gt;option check box is bind with the IsAllSelected property of the view model which has mode of two way as based on IsAllSelected value I have to do some processing for other checkbox so that the y will be checked or un-checked.
&lt;br /&gt;
&lt;script class="brush: xml" type="syntaxhighlighter"&gt;
&lt;![CDATA[
                &lt;checkbox Margin="10,5,5,0" Content="All" IsChecked="{Binding IsAllSelected,Mode=TwoWay}" /&gt;
                &lt;itemscontrol Margin="5" ItemsSource="{Binding CustomerList}"&gt;
                    &lt;ItemsControl.ItemsPanel&gt;
                        &lt;itemspaneltemplate&gt;
                            &lt;stackpanel Orientation="Vertical" /&gt;
                        &lt;/ItemsPanelTemplate&gt;
                    &lt;/ItemsControl.ItemsPanel&gt;
                    &lt;ItemsControl.ItemTemplate&gt;
                        &lt;datatemplate&gt;
                            &lt;checkbox Margin="5" ClickMode="Press" IsChecked="{Binding IsSelected, Mode=TwoWay}"&gt;
                                &lt;CheckBox.Content&gt;
                                    &lt;textblock&gt;
                                        &lt;run Text="{Binding FirstName}" /&gt;
                                        &lt;run Text="{Binding LastName}" /&gt;
                                    &lt;/TextBlock&gt;
                                &lt;/CheckBox.Content&gt;
                            &lt;/CheckBox&gt;
                        &lt;/DataTemplate&gt;
                    &lt;/ItemsControl.ItemTemplate&gt;
                &lt;/ItemsControl&gt;
]]&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 1&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Next is the item control tag here you can see that I have used stack panel layout for the Items Panel of the item control and in the item template I have used the check box control, the IsChecked property of checkbox is bind to the IsSelected property of the view model and the content property contain text block which is bind with the First name and the last name of the customer. Here you can see that Item control is bind with the CustomList which is collection of customer records.&lt;br /&gt;
Let me explain some of the code in the view model which is important. First is the property which is used to bind with the All option of the check box (which is used to checked  or un-checked all the check box control in the list so that user can select all the option of the checkbox list or un-check all the options.The IsAllSelected property code is listed in &lt;em&gt;List 2&lt;/em&gt;; here you can see that in the setter of the property I have some code which is used to set the IsSelected property of every record to true if the isAllSelected property is true and if the isAllSelected property is false then false is set to IsSelected property of every customer records.
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
&lt;![CDATA[
        Boolean _isAllSelected = false;
        public Boolean IsAllSelected {
            get { return _isAllSelected; }
            set {
                _isAllSelected = value;
                RaisePropertyChanged("IsAllSelected");
                _isAllSelectedExecution = true;
                foreach (Customer currentCustomer in CustomerList)
                    if (_isAllSelected)
                        currentCustomer.IsSelected = true;
                    else
                        currentCustomer.IsSelected = false;
                _isAllSelectedExecution = false;
            }
        }
]]&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 2&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
In the &lt;em&gt;List 2&lt;/em&gt; you have notice the variable _isAllSelectedExecution, which is used to restrict the execution of the individual check box IsChecked changed property code. At the start of the code I set true to the _isAllSelectedExecution variable so that it will restrict the code execution of the Individual checkbox property changed as we are for the time being executing the operation when user checked or un-checked the &lt;strong&gt;All&lt;/strong&gt; option.&lt;br /&gt;
Next is the code which is executed when user click any of the check box control other then &lt;b&gt;All &lt;/b&gt;option. Here you can see that at the start I have place condition to check the value of the _isAllSelectedExecution variable and if the value is true then it will return as the &lt;b&gt;All &lt;/b&gt;option code is being executed and we don’t want to execute the code as listed in &lt;i&gt;List 3&lt;/i&gt;.
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
&lt;![CDATA[
            void currentCustomer_PropertyChanged(object sender, PropertyChangedEventArgs e) {
            if (_isAllSelectedExecution)
                return;
            if ((sender as Customer).IsSelected == false) {
                _isAllSelected = false;
                RaisePropertyChanged("IsAllSelected");
            }
            else {
                _isAllSelected = true;
                RaisePropertyChanged("IsAllSelected");
                foreach (Customer currentCustomer in CustomerList)
                    if (currentCustomer.IsSelected == false) {
                        _isAllSelected = false;
                        RaisePropertyChanged("IsAllSelected");
                        break;
                    }
            }
        }
]]&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 3&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Next statement is to check the value of the sender IsSelected property if value is false then set the _isAllSelected to false and raises the notification property event; here I have used the private member to set the _isAllSelected value, if I set the IsAllSelected mean if I used the public property then it will un-checked all the checkbox as I have write code for checked and un-checked in the setter of the IsAllSelected property.In the else statement mean if the send IsSelected has value true then we need to check all the IsSelected properties of the customers so that if user checked all the check box in the list then &lt;b&gt;All &lt;/b&gt;option should be checked.In the code I will check for the first false value of the IsSelected and set false _isAllSelected property and raise the property changed event to notify the UI and then break the for each loop.&lt;br/&gt;
This is the easy way how to implement check box list control from my point of view if you have your own way to implement the checkbox list control then please do mention.You can download the source code of the sample from &lt;a href="http://asimsajjad.googlecode.com/files/Checkbox_List_Control.zip"&gt;&lt;span style="color: #2181b7;"&gt;here&lt;/span&gt;&lt;/a&gt;. &lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;All 
and any comments / bugs / suggestions are welcomed!&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;</description><link>http://asimsajjad.blogspot.com/2012/03/simple-way-to-create-checkbox-list-in.html</link><author>noreply@blogger.com (Asim Sajjad)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg15yvsMC5HtPj6yDNdwBfCN4Zl6_1vjaQYT0BxgQgXyZ27g7ULCJc-Edx5LGVf5dyWdk50q2T1EmKmFbRWuiHL2jvMSGmtPLhONCKHIzgk2fuO0xYa5cXZubGaYQzRj3yD_3kmNT8OU2M/s72-c/6-13-2012+8-25-04+PM.png" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5765821788458763196.post-9179367800232148086</guid><pubDate>Thu, 15 Mar 2012 10:54:00 +0000</pubDate><atom:updated>2012-06-11T15:54:46.926+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SilverLight</category><title>Silverlight ItemControl For Beginners</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Problem:&lt;/b&gt;        
                   &lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Need to display collection of item but don’t want mouse over effect and selected item effect like we have in list box control and in the data grid control.
&lt;/div&gt;
&lt;b&gt;Solution:&lt;/b&gt;
               &lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;To solve the above problem that we can display the collection of items in hierarchical way like data grid control or like the list box control but we don’t want the effect of mouse over (as we can also remove the mouse over effect and selected item effect of the data grid control and list box control by customizing the style of these controls but we don’t want to have) we can use the Item control which is design for this purpose.
&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
So we don’t want mouse over and selected item effect so we will use the item control for this purpose as it don’t have mouse over and selected item behavior  as you can see in the &lt;em&gt;Image 1&lt;/em&gt; here you can see that I have used the Item control to display the customer  information. User can view the customer information but can’t select the item from the list as he/she can use in list box and data grid control
&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSfVijhOQhBwszAlzHyM0OITIbtGtGnBYVA3wAJ_CUZdA4Xv9wa7SeIN3xDVkB_aPjWCKpYPYMPcpUZrJQBD3D9Gx5uS93_on3mtYsFw36ZjqRymtHTktogQ7fZVwy9urrwXjd6LwEs28/s1600/Image+01.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSfVijhOQhBwszAlzHyM0OITIbtGtGnBYVA3wAJ_CUZdA4Xv9wa7SeIN3xDVkB_aPjWCKpYPYMPcpUZrJQBD3D9Gx5uS93_on3mtYsFw36ZjqRymtHTktogQ7fZVwy9urrwXjd6LwEs28/s400/Image+01.png" width="234" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;strong&gt;Image 1&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;script class="brush: xml" type="syntaxhighlighter"&gt;
&lt;![CDATA[
     &lt;ItemsControl.Template&gt;
           &lt;controltemplate&gt;
               &lt;scrollviewer x:Name="ScrollViewer" Padding="{TemplateBinding Padding}"&gt;
                   &lt;itemspresenter /&gt;
               &lt;/ScrollViewer&gt;
           &lt;/ControlTemplate&gt;
     &lt;/ItemsControl.Template&gt;
]]&gt;
&lt;/script&gt;
&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 1&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Let us start with the code how to insert the item control in the xaml and then bind the item control with the collection of item using MVVM (I have used MVVM pattern for this sample code if you have code behind then you can set the Item source of the item control in code behind by using the name of the control which you specify in the xaml).In the &lt;i&gt;List 1&lt;/i&gt; I have posted the code for the template of the Item control how the item control will looks. Here you can see that I have only use the scroll viewer control so if we have more items then it will show scrolling vertically as in my example item as display vertically. And then the Item presenter which will be the place holder for the items of the Item control will be displayed. So I have placed the scroll viewer only in the item control template and didn’t mention other attributes like background color , border color , font color etch for the entire item control.

&lt;script class="brush: xml" type="syntaxhighlighter"&gt;
&lt;![CDATA[
                &lt;ItemsControl.ItemTemplate&gt;
                &lt;datatemplate&gt;
                    &lt;grid Margin="5"&gt;
                        &lt;Grid.RowDefinitions&gt;
                            &lt;rowdefinition Height="25" /&gt;
                            &lt;rowdefinition Height="25" /&gt;
                            &lt;rowdefinition Height="25" /&gt;
                            &lt;rowdefinition Height="25" /&gt;
                        &lt;/Grid.RowDefinitions&gt;
                        &lt;Grid.ColumnDefinitions&gt;
                            &lt;columndefinition Width="90" /&gt;
                            &lt;columndefinition /&gt;
                        &lt;/Grid.ColumnDefinitions&gt;
                        &lt;border Grid.RowSpan="3" Grid.ColumnSpan="2" Margin="2" BorderBrush="{StaticResource ControlBackgroundOverOrange}" BorderThickness="1" CornerRadius="2" /&gt;
                        &lt;textblock Margin="5,0" VerticalAlignment="Center" Style="{StaticResource ContentTextStyle}" Text="First Name :" /&gt;
                        &lt;textblock Grid.Row="0" Grid.Column="1"  Margin="5,0" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="12" Style="{StaticResource ContentTextStyle}" Text="{Binding Path=FirstName}" /&gt;

                        &lt;textblock Grid.Row="1" Grid.Column="0" Margin="5,0" VerticalAlignment="Center" Style="{StaticResource ContentTextStyle}" Text="Last Name :" /&gt;

                        &lt;textblock Grid.Row="1" Grid.Column="1" Margin="5,0" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="12" Style="{StaticResource ContentTextStyle}" Text="{Binding Path=LastName}" /&gt;

                        &lt;textblock Grid.Row="2" Grid.Column="0" Margin="5,0" VerticalAlignment="Center" Style="{StaticResource ContentTextStyle}" Text="Address :" /&gt;

                        &lt;textblock Grid.Row="2" Grid.Column="1" Margin="5,0" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="12" Style="{StaticResource ContentTextStyle}" Text="{Binding Path=Address}" /&gt;

                        &lt;border Grid.Row="4" Grid.ColumnSpan="2" Height="1" Margin="30,0" Background="{StaticResource ControlBackgroundOverOrange}" /&gt;
                    &lt;/Grid&gt;
                &lt;/DataTemplate&gt;
            &lt;/ItemsControl.ItemTemplate&gt;
]]&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 2&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Next is how to display the Item in item control. Here as you can see in the&lt;em&gt; Image 1&lt;/em&gt; that I have use card view border around the customer information and then horizontal line at the end.Here I have used the Item template as you can see in the List 2 and then inside the Item template I have used the data template or organization the detail of the each of the customer.Code for the Data template for the item template is shown in the &lt;i&gt;List 2&lt;/i&gt;. 
&lt;br /&gt;
You can use the mouse event for the item control perform opertion like on mouse over you can display tooltip which will show further detail of the customer. Hope you have some idea of how to use the item control and if you have similar requirement to use the control which don't have the mouse over and selected item behaviour then you can use the item control instead of customize the list box or data grid control.You can download the source code of the sample from &lt;a href="http://asimsajjad.googlecode.com/files/Silverlight_ItemControl.zip"&gt;&lt;span style="color: #2181b7;"&gt;here&lt;/span&gt;&lt;/a&gt;.
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;All and any 
comments / bugs / suggestions are welcomed!&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</description><link>http://asimsajjad.blogspot.com/2012/03/silverlight-itemcontrol-for-beginners.html</link><author>noreply@blogger.com (Asim Sajjad)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSfVijhOQhBwszAlzHyM0OITIbtGtGnBYVA3wAJ_CUZdA4Xv9wa7SeIN3xDVkB_aPjWCKpYPYMPcpUZrJQBD3D9Gx5uS93_on3mtYsFw36ZjqRymtHTktogQ7fZVwy9urrwXjd6LwEs28/s72-c/Image+01.png" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5765821788458763196.post-1813010253170281986</guid><pubDate>Mon, 12 Mar 2012 09:45:00 +0000</pubDate><atom:updated>2012-06-08T09:49:06.966+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">MS CRM 2011</category><category domain="http://www.blogger.com/atom/ns#">SilverLight</category><title>Microsoft CRM 2011 Silverlight: Busy Indicator Style</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div style="text-align: justify;"&gt;
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 &lt;i&gt;Image 1 &lt;/i&gt;as shown.&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiYNOI8N8g9khqVAKMCvSq5g2QDJ4YSkwvzZuYZUB75fCJNgZQmk3yioc9bFa1Mn7AF2l_NI6hA3WAZTABVq2CmzhzEk1W9hWD0RYoYgeOsFyJ-1umJdhicVNhAhzN_rzWqjyTMEmQLpI/s1600/6-6-2012+2-23-11+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="154" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiYNOI8N8g9khqVAKMCvSq5g2QDJ4YSkwvzZuYZUB75fCJNgZQmk3yioc9bFa1Mn7AF2l_NI6hA3WAZTABVq2CmzhzEk1W9hWD0RYoYgeOsFyJ-1umJdhicVNhAhzN_rzWqjyTMEmQLpI/s320/6-6-2012+2-23-11+PM.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;&amp;nbsp;Image 1&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;script class="brush: xml" type="syntaxhighlighter"&gt;
&lt;![CDATA[
  &lt;grid x:Name="LayoutRoot"
          Background="White"
          ShowGridLines="True"&gt;
        &lt;Grid.RowDefinitions&gt;
            &lt;rowdefinition /&gt;
            &lt;rowdefinition /&gt;
        &lt;/Grid.RowDefinitions&gt;
        &lt;toolkit:BusyIndicator Margin="5"
                               VerticalAlignment="Stretch"
                               Foreground="DarkGray"
                               IsBusy="True" /&gt;
        &lt;toolkit:BusyIndicator Grid.Row="1"
                               Margin="5"
                               VerticalAlignment="Stretch"
                               Foreground="DarkGray"
                               IsBusy="True"
                               Style="{StaticResource BusyIndicatorStyle1}" /&gt;
    &lt;/Grid&gt;
    
]]&gt;
&lt;/script&gt;
&lt;br /&gt;
&lt;div style="font-family: Times,&amp;quot;Times New Roman&amp;quot;,serif; text-align: center;"&gt;
&lt;b&gt;List 1&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
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 &lt;i&gt;List 1&lt;/i&gt;, 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.&lt;br /&gt;
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 &lt;a href="http://asimsajjad.googlecode.com/files/Busy%20Indicator%20Style.zip"&gt;&lt;span style="color: #2181b7;"&gt;here&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;
&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
You can view online sample &lt;a href="http://gallery.expression.microsoft.com/CRM2011BusyIndicator?SRC=Home" target="_blank"&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;All and any comments / bugs /  suggestions are welcomed!&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</description><link>http://asimsajjad.blogspot.com/2012/03/microsoft-crm-2011-silverlight-busy.html</link><author>noreply@blogger.com (Asim Sajjad)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiYNOI8N8g9khqVAKMCvSq5g2QDJ4YSkwvzZuYZUB75fCJNgZQmk3yioc9bFa1Mn7AF2l_NI6hA3WAZTABVq2CmzhzEk1W9hWD0RYoYgeOsFyJ-1umJdhicVNhAhzN_rzWqjyTMEmQLpI/s72-c/6-6-2012+2-23-11+PM.png" width="72"/><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5765821788458763196.post-4801044973105529435</guid><pubDate>Sat, 10 Mar 2012 03:08:00 +0000</pubDate><atom:updated>2012-03-10T08:08:52.925+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Learning C#</category><category domain="http://www.blogger.com/atom/ns#">Linq</category><title>Select Distinct Using Linq</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Problem:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; We have a list and when want to filter the list based on property to get the unique List.
&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Solution:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 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 &lt;i&gt;List 1&lt;/i&gt; 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.&lt;/div&gt;
&lt;/div&gt;
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
&lt;![CDATA[
        class Program {
        static void Main(string[] args) {

            List&lt;employee&gt; _employeeList = new List&lt;employee&gt;();
            _employeeList.Add(new Employee() { EmployeeId = 1, Name = "Employee A", City = "Islamabad" });
            _employeeList.Add(new Employee() { EmployeeId = 2, Name = "Employee B", City = "Lahore" });
            _employeeList.Add(new Employee() { EmployeeId = 3, Name = "Employee C", City = "Karachi" });
            _employeeList.Add(new Employee() { EmployeeId = 4, Name = "Employee D", City = "Islamabad" });
            _employeeList.Add(new Employee() { EmployeeId = 5, Name = "Employee E", City = "Islamabad" });
            _employeeList.Add(new Employee() { EmployeeId = 6, Name = "Employee A", City = "Islamabad" });
            _employeeList.Add(new Employee() { EmployeeId = 7, Name = "Employee F", City = "Islamabad" });
            _employeeList.Add(new Employee() { EmployeeId = 8, Name = "Employee B", City = "Lahore" });
            _employeeList.Add(new Employee() { EmployeeId = 9, Name = "Employee C", City = "Karachi" });

            var distinctEmployeeList = _employeeList.GroupBy(param =&gt; param.Name).Select(param =&gt; param.First());
            Console.WriteLine(string.Format("List with distinct employee names"));
            foreach(Employee currentEmployee in distinctEmployeeList)
                Console.WriteLine(string.Format("Employee Id: {0} , Employee Name: {1}, City: {2}", currentEmployee.EmployeeId,currentEmployee.Name,currentEmployee.City));

            distinctEmployeeList = _employeeList.GroupBy(param =&gt; param.City).Select(param =&gt; param.First());
            Console.WriteLine(string.Format("List with distinct cities"));
            foreach (Employee currentEmployee in distinctEmployeeList)
                Console.WriteLine(string.Format("Employee Id: {0} , Employee Name: {1}, City: {2}", currentEmployee.EmployeeId, currentEmployee.Name, currentEmployee.City));
        }
    }

    public class Employee {
        public int EmployeeId { get; set; }
        public string Name { get; set; }
        public string City { get; set; }
    }
]]&gt;
&lt;/script&gt;
&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 1&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
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.
&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidGxDoVj9CtdP-yzHNlp765stCWGUZi1g1StfItBJsaJP2_LTq-iEk3nXwHgsF9zYeE_FO_SN_zz6lROL2nc54vugg9iC1iKnf6JMHHoolsvIM3B2OQLymtZQOmlSyZyXyC5lWCKZQYqw/s1600/3-10-2012+6-58-12+AM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="119" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidGxDoVj9CtdP-yzHNlp765stCWGUZi1g1StfItBJsaJP2_LTq-iEk3nXwHgsF9zYeE_FO_SN_zz6lROL2nc54vugg9iC1iKnf6JMHHoolsvIM3B2OQLymtZQOmlSyZyXyC5lWCKZQYqw/s400/3-10-2012+6-58-12+AM.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 1&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
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.&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
In the next distinct statement I have used the city , so that the resultant record are distinct on the city name and in the &lt;i&gt;Image 1&lt;/i&gt; 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.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
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.&lt;/div&gt;
&lt;br /&gt;
&lt;b xmlns="http://www.w3.org/1999/xhtml"&gt;All and any comments / bugs /  suggestions are welcomed!&lt;/b&gt;
&lt;/div&gt;</description><link>http://asimsajjad.blogspot.com/2012/03/select-distinct-using-linq.html</link><author>noreply@blogger.com (Asim Sajjad)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidGxDoVj9CtdP-yzHNlp765stCWGUZi1g1StfItBJsaJP2_LTq-iEk3nXwHgsF9zYeE_FO_SN_zz6lROL2nc54vugg9iC1iKnf6JMHHoolsvIM3B2OQLymtZQOmlSyZyXyC5lWCKZQYqw/s72-c/3-10-2012+6-58-12+AM.png" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5765821788458763196.post-8215286297583516824</guid><pubDate>Sun, 26 Feb 2012 07:47:00 +0000</pubDate><atom:updated>2012-02-26T12:47:42.612+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SilverLight</category><title>Multi Select ComboBox in Silverlight</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Problem:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Need a way to use the combo box of silverlight which has check boxes and user can select multiple options from the combo box.&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;Solution:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; When I came across this requirement to implement the multi selection in combo box the first thing which I have done which many of the developer do is to search on the Google for possible solution.The solution which I found is from the &lt;a href="http://stackoverflow.com/questions/3914405/combobox-display-value-in-silverlight" target="_blank"&gt;stack over flow&lt;/a&gt;, here you can see it has give complete code and you can easily implement it. But here in my post I have changed some of the code but the the user control which is inherit from combo box. I will explain you where I have modified the code as I discuss it.&lt;br /&gt;
The main application which I have used for this is shown in &lt;i&gt;image 1&lt;/i&gt; here you can see a combo box control which is used for multiple selection and a data grid control which filter records based on the selected item from combo box. In this test application I am using the customer xml to show the records in the data grid control and I have get the countries names in the combo box control so that user can select country or countries to filter out the records in the data grid control.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZ7Koi9lhFVWBUhxe2U1b8H2QhOXThnX2RXP1F57seuTHRN7Wpqls5trIP8ggdyZ_f51Ca7fAYX9HP_znzLwl9X1g9lHDf5NodIrEyApYFbhi8kXsxkEs6IRamblZuTSHiw-TJWo0xyA8/s1600/Main.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="282" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZ7Koi9lhFVWBUhxe2U1b8H2QhOXThnX2RXP1F57seuTHRN7Wpqls5trIP8ggdyZ_f51Ca7fAYX9HP_znzLwl9X1g9lHDf5NodIrEyApYFbhi8kXsxkEs6IRamblZuTSHiw-TJWo0xyA8/s400/Main.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 1&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style="text-align: justify;"&gt;
Let use discuss code for the sample application. As I have said that the control which inherit from the combo box is same as you can see on the post on the &lt;a href="http://stackoverflow.com/questions/3914405/combobox-display-value-in-silverlight" target="_blank"&gt;stack over flow&lt;/a&gt; but the code which I have modified is the model of the combo box item and the text property of the combo box which is dependency property to show the comma separate values of the selected record of the combo box control.
&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
The first thing which I have modified is the item source collection of the combo box which raise the checked changed event I have inherit from INotifyPropertyChanged interface and use it to raise the property changed event of the class. As you can see in the code in List 1 that I have only raise the property changed for the IsChecked property which is of boolean type is bind to the IsChecked Property of the check box control which is place inside the combo box control.
&lt;/div&gt;
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
&lt;![CDATA[
     public class ComboBoxItemsModel : INotifyPropertyChanged
    {
        private bool _isChecked;

        public bool IsChecked
        {
            get { return _isChecked; }
            set
            {
                _isChecked = value;
                NotifyPropertyChanged("IsChecked");
            }
        }

        public string Text { get; set; }


        #region " INotifyPropertyChanged Interface "

        // Declare the PropertyChanged event
        public event PropertyChangedEventHandler PropertyChanged;

        // NotifyPropertyChanged will raise the PropertyChanged event passing the
        // source property that is being updated.
        public void NotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
        #endregion

    }
]]&gt;
&lt;/script&gt;
&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 1&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Next is some modification in the view model of the Home view which is located in the viewModel folder, The thing which I modified is the display value of the combo box, in original post &lt;a href="http://stackoverflow.com/questions/3914405/combobox-display-value-in-silverlight" target="_blank"&gt;stack over flow&lt;/a&gt; if you implement the code as it is or read it you can see that combo box will display selected item is comma separated format but I have display the static text "Select Country" and don't display the comma separated value.&lt;br /&gt;
In &lt;i&gt;List 2&lt;/i&gt; I have code which is used to populate the list for the combo box, here you can see that function take list of customer and then by using the LINQ get the distinct country name which are order by country and after getting the countries I have populate the ComboBoxList which is of type "ComboBoxItemsModel " which is listed in &lt;i&gt;List 1&lt;/i&gt;. Here you can see that I have created new object and then attached the PropertyChanged with the newly created object and assign text and then add in the list.
&lt;/div&gt;
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
&lt;![CDATA[
        public void Fill_ComboBox_List(List&lt;customer&gt; customerList) {
            var distinctCountries = (from p in customerList
                                     orderby p.Country
                                     select p.Country
                                     ).Distinct();

            foreach (string strCountryName in distinctCountries)
            {
                ComboBoxItemsModel cboItemModel = new ComboBoxItemsModel();
                cboItemModel.PropertyChanged += new PropertyChangedEventHandler(cboItemModel_PropertyChanged);
                cboItemModel.Text = strCountryName;
                ComboBoxsList.Add(cboItemModel);
            }
        }
        
        void cboItemModel_PropertyChanged(object sender, PropertyChangedEventArgs e) {
            strSelectedCountries = string.Join(",", ComboBoxsList.Where(param =&gt; param.IsChecked).Select(param =&gt; param.Text));
            CustomersList.Refresh();
        }
       
]]&gt;
&lt;/script&gt;
&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 2&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
I have used same code to get the selected item as I need to check the country or countries name is the list and then filter the data grid records which used the PagedCollectionView as filtering of record is quite easy if you use the PagedCollectionView. If you didn't know about the PagedCollectionView filter then you can refer to my &lt;a href="http://asimsajjad.blogspot.com/2011/09/using-pagedcollectionview-filter-using.html"&gt;post &lt;/a&gt;for detail. After getting the comma separate value of the selected item from the combo box list I have just called the Refresh function of the PagedCollectionView to Refresh the collection of the data grid control to display the filtered records.
&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
The last code which is listed in &lt;i&gt;List 3 &lt;/i&gt; is the xaml code for the combo box. Here you can see that I have bind the Text Property of the combo box as it was bind in the original code and item source the only thing which I have changed in this code is the ItemTemplate I have used the combo box item template.
&lt;/div&gt;
&lt;script class="brush: xml" type="syntaxhighlighter"&gt;
&lt;![CDATA[
      &lt;controls:MyComboBox Width="250"
                                 Height="28"
                                 Margin="5,0"
                                 MaxDropDownHeight="100"
                                 ItemsSource="{Binding ComboBoxsList}"
                                 Style="{StaticResource ComboBoxStyle}"
                                 Text="{Binding ComboBoxText}"&gt;
                &lt;ComboBox.ItemTemplate&gt;
                    &lt;datatemplate&gt;
                        &lt;grid HorizontalAlignment="Left"&gt;
                            &lt;checkbox Content="{Binding Text}"
                                      Foreground="Black"
                                      IsChecked="{Binding IsChecked,
                                                          Mode=TwoWay}" /&gt;
                        &lt;/Grid&gt;
                    &lt;/DataTemplate&gt;
                &lt;/ComboBox.ItemTemplate&gt;
            &lt;/controls:MyComboBox&gt;
]]&gt;
&lt;/script&gt;
&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 3&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;i&gt;&lt;b&gt;Note: &lt;/b&gt;As you can see that in the xaml code for the combo box, that the tag for the combo box is change not the ComboBox which is the default control for the silverlight. So you have to create separate style for the newly create control with the controls:MyComboBox tag so that it can apply to the custom combo box control. I have created one for my control which you can find in the app.xaml file.
&lt;/i&gt;&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjXioPQwOxnyLeiqzrkKB9rVuqT7zV2Yc4kkuupM97lRFR5X44eLtOineJEiUmXG1DOFY-tEsw6QvuQmq_aX8qE3IccDwlvM7B65fAPYQikgGBdAYYpfdYGuBRDM11vaOqarDLhcpJypM/s1600/2-26-2012+7-47-20+AM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="193" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjXioPQwOxnyLeiqzrkKB9rVuqT7zV2Yc4kkuupM97lRFR5X44eLtOineJEiUmXG1DOFY-tEsw6QvuQmq_aX8qE3IccDwlvM7B65fAPYQikgGBdAYYpfdYGuBRDM11vaOqarDLhcpJypM/s400/2-26-2012+7-47-20+AM.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 2&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style="text-align: left;"&gt;
&lt;div style="text-align: justify;"&gt;
Output of the can be seen in the Image 2, here you can see that I have selected three countries and records for the selected countries are displayed in the grid. After filter I have sort the grid records by using the country.You can download the source code of the sample from &lt;a href="http://asimsajjad.googlecode.com/files/MultiSelect%20ComboBox.zip"&gt;&lt;span style="color: #2181b7;"&gt;here&lt;/span&gt;&lt;/a&gt;.


&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;All and any comments / bugs /  suggestions are welcomed!&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</description><link>http://asimsajjad.blogspot.com/2012/02/multi-select-combobox-in-silverlight.html</link><author>noreply@blogger.com (Asim Sajjad)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZ7Koi9lhFVWBUhxe2U1b8H2QhOXThnX2RXP1F57seuTHRN7Wpqls5trIP8ggdyZ_f51Ca7fAYX9HP_znzLwl9X1g9lHDf5NodIrEyApYFbhi8kXsxkEs6IRamblZuTSHiw-TJWo0xyA8/s72-c/Main.png" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5765821788458763196.post-3404589706918124279</guid><pubDate>Sat, 04 Feb 2012 02:12:00 +0000</pubDate><atom:updated>2012-02-18T14:45:20.555+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Javascript</category><category domain="http://www.blogger.com/atom/ns#">MS CRM 2011</category><title>Delete Record Using oData Call</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Problem:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Need to delete record from Microsoft CRM 2011 by using the oData call in Microsoft CRM 2011.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Solution:&lt;/b&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The solution to delete record using oData call is similar to the what we have done in my last post "&lt;a href="http://asimsajjad.blogspot.com/2012/02/update-record-using-odata-call.html"&gt;Update Record Using oData Call&lt;/a&gt;" where we use the current record Id to update the record here we use same code but with some modification to delete the current record. You can see the code in the List 1 , here you can see similar code which I have used for update of record in "&lt;a href="http://asimsajjad.blogspot.com/2012/02/update-record-using-odata-call.html"&gt;Update Record Using oData Call&lt;/a&gt;" post with some modification. First I have only passed the record Id which is used for the delete purpose. Second is the X-HTTP-Method here I have passed DELETE as I am performing the delete operation for the passed GUID.
&lt;/div&gt;
&lt;script class="brush: javascript" type="syntaxhighlighter"&gt;
&lt;![CDATA[
function DeleteAccount() {
    if (confirm("Do you want to delete this account record?")) {
        debugger;
        var ODataPath = Xrm.Page.context.getServerUrl() + "/XRMServices/2011/OrganizationData.svc";

        var deleteAccountRequest = new XMLHttpRequest();
        deleteAccountRequest.open("POST", ODataPath + "/AccountSet(guid'" + Xrm.Page.data.entity.getId() + "')", true);
        deleteAccountRequest.setRequestHeader("Accept", "application/json");
        deleteAccountRequest.setRequestHeader("Content-Type", "application/json; charset=utf-8");
        deleteAccountRequest.setRequestHeader("X-HTTP-Method", "DELETE");

        deleteAccountRequest.onreadystatechange = function () {
            onAccountDeleteCallBack(this, Xrm.Page.data.entity.getId());
        };
        deleteAccountRequest.send();
    }
}

function onAccountDeleteCallBack(updateAccountReturnValue, accountId) {
    if (updateAccountReturnValue.readyState == 4 /* complete */) {
        debugger;
        if ((updateAccountReturnValue.status == 204) ||
            (updateAccountReturnValue.status == 1223)) {
            alert("Account with Id : " + accountId + " deleted successfully.");
        }
        else
            alert("Error occurred while updating record.");
    }
}
]]&gt;
&lt;/script&gt;
&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 1&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
And the last modification in the code is the send method of the XMLHttpRequest, here I didn't pass any parameter.On successful deletion of the record it will return status of the 204 or 1223 same as used for the update.
Above is the sample piece of code which is used to delete the record by using oData call.&lt;/div&gt;
&lt;br /&gt;
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;All and any comments / bugs /  suggestions are welcomed!&lt;/b&gt;&lt;/span&gt; &lt;/div&gt;</description><link>http://asimsajjad.blogspot.com/2012/02/delete-record-using-odata-call.html</link><author>noreply@blogger.com (Asim Sajjad)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5765821788458763196.post-2997342483416742441</guid><pubDate>Fri, 03 Feb 2012 06:25:00 +0000</pubDate><atom:updated>2012-02-12T11:26:15.878+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Javascript</category><category domain="http://www.blogger.com/atom/ns#">MS CRM 2011</category><title>Update Record Using oData Call</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Problem:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Need to update existing record from the JavaScript by using the oData call in Microsoft CRM 2011. 
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Solution:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For updating the existing record I have used the same record which I have created in my last post "&lt;a href="http://asimsajjad.blogspot.com/2012/02/insert-new-record-in-micosoft-crm-2011.html" target="_blank"&gt;Insert New Record In Micosoft CRM 2011 Using oData Call&lt;/a&gt; ", where I have created new record by using odata call in JavaScript. You can see in the Image 1, here you can see that I have highlighted the Main Phone and the address : City , mean I am going to update these fields Main Phone and the address of the account is going to update using the code here.&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzc7dRF_4VJMDNq8zQod9vMgKYIfX9SWAU-cpt6hClc0AsPszSlk863JPeSxgzIbhy3qk15ct97hyphenhyphenuDRTVDr_YYmXlCUtMGDkfSdp29BgH2b-52I0XxxQelRJEFgvatWTCnuX7pggcuEo/s1600/2-12-2012+7-07-53+AM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="169" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzc7dRF_4VJMDNq8zQod9vMgKYIfX9SWAU-cpt6hClc0AsPszSlk863JPeSxgzIbhy3qk15ct97hyphenhyphenuDRTVDr_YYmXlCUtMGDkfSdp29BgH2b-52I0XxxQelRJEFgvatWTCnuX7pggcuEo/s400/2-12-2012+7-07-53+AM.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 1&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Code for updating record using oData call in JavaScript is listed in &lt;i&gt;List 1&lt;/i&gt; here you can see that I have first created object for updating the account record then I have used the Address1 to update the City, Line1, Postal code and State or Province of the address and then at the end I have used the Main Phone to be updated.&lt;/div&gt;
&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;script class="brush: javascript " type="syntaxhighlighter"&gt;
&lt;![CDATA[
function UpdateAccount() {
    var ODataPath = Xrm.Page.context.getServerUrl() + "/XRMServices/2011/OrganizationData.svc";

    var updateAccountRecord = {};
    updateAccountRecord.Address1_AddressTypeCode = { Value: 3 }; //Address 1: Address Type = Primary
    updateAccountRecord.Address1_City = "Sammamish";
    updateAccountRecord.Address1_Line1 = "123 Maple St.";
    updateAccountRecord.Address1_PostalCode = "98074";
    updateAccountRecord.Address1_StateOrProvince = "WA";
    updateAccountRecord.Telephone1 = "555-0115";

    var updateAccountRequest = new XMLHttpRequest();
    updateAccountRequest.open("POST", ODataPath + "/AccountSet(guid'" + Xrm.Page.data.entity.getId() + "')", true);
    updateAccountRequest.setRequestHeader("Accept", "application/json");
    updateAccountRequest.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    updateAccountRequest.setRequestHeader("X-HTTP-Method", "MERGE");

    updateAccountRequest.onreadystatechange = function () {
        onAccountUpdateCallBack(this, Xrm.Page.data.entity.getId());
    };
    updateAccountRequest.send(JSON.stringify(updateAccountRecord));

}

function onAccountUpdateCallBack(updateAccountReturnValue, accountId) {
    if (updateAccountReturnValue.readyState == 4 /* complete */) {
        if ((updateAccountReturnValue.status == 204) ||
            (updateAccountReturnValue.status == 1223)) {
            alert("Account with Id : " + accountId + " updated successfully.");
        }
        else
            alert("Error occurred while updating record.");
    }
}
]]&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 1&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
After creating the account object for update, next is to create the request object for the oData call, here I have created updateAccountRequest which is used to update the account record. Next is open function of the request which take "POST" as first argument as we are posting data to the server and in the next parameter for the URL note that here we have to pass the Id of the record which is going to be updated by this call. The statement which need to be noted is listed in the &lt;i&gt;List 2&lt;/i&gt; here you can see that in case of update we need to use this extra statement so that record will be updated. For X-HTTP-Method you can refer to the following &lt;a href="http://msdn.microsoft.com/en-us/library/dd541471%28v=prot.10%29.aspx"&gt;link&lt;/a&gt; Here you can find detail of X-HTTP-Method. We have use the marge request which updates only the properties indicated in the request body, and leaves untouched anything not mentioned in its current state.&lt;br /&gt;
&lt;br /&gt;
&lt;script class="brush: xml" type="syntaxhighlighter"&gt;
&lt;![CDATA[
        updateAccountRequest.setRequestHeader("X-HTTP-Method", "MERGE");
]]&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 2&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
Next is the send function of the HttpRequest to send the updated object and also attached the callback function with the request object.&amp;nbsp; Here you can see that I have passed record Id to the callback function so that if record is updated successfully then Id will be shown to the client with message and one thing that you can also pass parameter to the completed or callback function which is attached with the request object, mean if you want to send some information which you need in the callback function.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
In the callback function I just check the status of the the request for 204 and 1223 as it is the update option and it will return different status. In case of successful it will display message to the client and the if you refresh the active account then you can see the Main Phone and the Address1 : City are update for the record you can see in the &lt;i&gt;Image 2&lt;/i&gt; as below.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCeaLdIz13P3s9sDSKwJ4AfNYvQ2UwX58sHQj8Y12YUv0Wl3OZSmzkaP22QJqKvrJ2Ings-Ipe57HAguE-QnwS-Z3Lfb0SSX9UiSbcctKa2_CtUnF514hLfTjd6YmN-AbKGKwY7xdfjbc/s1600/2-12-2012+7-08-52+AM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="168" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCeaLdIz13P3s9sDSKwJ4AfNYvQ2UwX58sHQj8Y12YUv0Wl3OZSmzkaP22QJqKvrJ2Ings-Ipe57HAguE-QnwS-Z3Lfb0SSX9UiSbcctKa2_CtUnF514hLfTjd6YmN-AbKGKwY7xdfjbc/s400/2-12-2012+7-08-52+AM.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 2&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style="text-align: justify;"&gt;
This is how you can use the oData call to update the record by using JavaScript. I have used simple attribute to update on load of the form you can use this technique.&lt;br /&gt;

&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;All and any comments / bugs /  suggestions are welcomed!&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;</description><link>http://asimsajjad.blogspot.com/2012/02/update-record-using-odata-call.html</link><author>noreply@blogger.com (Asim Sajjad)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzc7dRF_4VJMDNq8zQod9vMgKYIfX9SWAU-cpt6hClc0AsPszSlk863JPeSxgzIbhy3qk15ct97hyphenhyphenuDRTVDr_YYmXlCUtMGDkfSdp29BgH2b-52I0XxxQelRJEFgvatWTCnuX7pggcuEo/s72-c/2-12-2012+7-07-53+AM.png" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5765821788458763196.post-5404849963941972420</guid><pubDate>Thu, 02 Feb 2012 01:55:00 +0000</pubDate><atom:updated>2012-02-11T06:56:06.021+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Javascript</category><category domain="http://www.blogger.com/atom/ns#">MS CRM 2011</category><title>DateTime Format While Retrieving Using oData</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Problem: &lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; While retrieving date attribute using oData call, the format of date is not correct , need to format data value so that it can be user friendly. As you can see in the &lt;i&gt;Image 1&lt;/i&gt;.&lt;/div&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhanRLcpV4Nz11yIW2c6DjDuskUgsca-X0IYy_S1U-aPemPjFmi6Z1JDNHUce3zhQlIPE8Ows2q9hlzMkuum3Ex_ETAYHcxwSkL_oc5qfKxapDPJqu337ezx5WENLgHuxYXOGSWVSltVN8/s1600/2-11-2012+6-28-43+AM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="79" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhanRLcpV4Nz11yIW2c6DjDuskUgsca-X0IYy_S1U-aPemPjFmi6Z1JDNHUce3zhQlIPE8Ows2q9hlzMkuum3Ex_ETAYHcxwSkL_oc5qfKxapDPJqu337ezx5WENLgHuxYXOGSWVSltVN8/s400/2-11-2012+6-28-43+AM.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 1&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;b&gt;Solution: &lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The solution of the above problem is listed in &lt;i&gt;List 1&lt;/i&gt;. Here you can see that I have taken this code from my post "&lt;a href="http://asimsajjad.blogspot.com/2012/02/insert-new-record-in-micosoft-crm-2011.html" target="_blank"&gt;Insert New Record In Micosoft CRM 2011 Using oData Call&lt;/a&gt; ", where I have show you how to insert new record by using oData call and you can see in Image 2 of the last post date is not correctly formatted. Here in the code I have modified the completed callback of the Account create async call of my post "&lt;a href="http://asimsajjad.blogspot.com/2012/02/insert-new-record-in-micosoft-crm-2011.html" target="_blank"&gt;Insert New Record In Micosoft CRM 2011 Using oData Call&lt;/a&gt; . &lt;/div&gt;
&lt;br /&gt;
&lt;script class="brush: javascript" type="syntaxhighlighter"&gt;
&lt;![CDATA[
    function onAccountCreateCallBack(createAccountReturnValue) {
    if (createAccountReturnValue.readyState == 4 /* complete */) {
        if (createAccountReturnValue.status == 201) {
            var createAccountReturnValue = JSON.parse(createAccountReturnValue.responseText).d;
            if (createAccountReturnValue != null) {
                if (createAccountReturnValue.Name != null) {
                    var stringDateValue = eval(createAccountReturnValue.CreatedOn).toString();
                    var dateValue = new Date(parseInt(stringDateValue.replace("/Date(", "").replace(")/", ""), 10));
                    alert("Retrieved the account named \"" + createAccountReturnValue.Name + "\". This account was created on : \"" + dateValue+ "\".");
                }
            }
        }
        else
            alert("Error occured while inserting new record.");
  
]]&gt;
&lt;/script&gt;
&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 1&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
You can see in above code that I have first store CreatedOn value in the stringDataValue object by using eval and converting to string so that I can perform string function on that. In the next statement I have used the Date constructor to create the date, In the Data constructor I have used the parseInt function of JavaScript to parse the value which is return by using the replace function of the string, then I have replace the unwanted characters from the data value like "/Data(" and  ")/" so that I have the exact integer value of the date.You can see the output of the result in &lt;i&gt;Image 2&lt;/i&gt;.&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnfTYLgVwsxJvOZKGzToOCKcQKt-20vIMHIOTkmtVdXY3OItgOE0AwKsqeQzK9c08ax72UiXRUekxke2FmflNiRA9TyNpxJ9Q6y0MJLYQTIWlCKI8zK1Eie2uPco_N_ITCzKNsTpkzeuU/s1600/2-11-2012+6-36-41+AM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="72" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnfTYLgVwsxJvOZKGzToOCKcQKt-20vIMHIOTkmtVdXY3OItgOE0AwKsqeQzK9c08ax72UiXRUekxke2FmflNiRA9TyNpxJ9Q6y0MJLYQTIWlCKI8zK1Eie2uPco_N_ITCzKNsTpkzeuU/s400/2-11-2012+6-36-41+AM.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
That is how you can format the date when you use the odata call to get the date attribute of the entity. As you can see that the output also show you the time zone as well here it will show +5 for my time zone you can use this as well if you have different time value to shown based on your requirements.
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;All and any comments / bugs /  suggestions are welcomed!&lt;/b&gt;&lt;/span&gt;
&lt;/div&gt;</description><link>http://asimsajjad.blogspot.com/2012/02/datetime-format-while-retrieving-using.html</link><author>noreply@blogger.com (Asim Sajjad)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhanRLcpV4Nz11yIW2c6DjDuskUgsca-X0IYy_S1U-aPemPjFmi6Z1JDNHUce3zhQlIPE8Ows2q9hlzMkuum3Ex_ETAYHcxwSkL_oc5qfKxapDPJqu337ezx5WENLgHuxYXOGSWVSltVN8/s72-c/2-11-2012+6-28-43+AM.png" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5765821788458763196.post-7664315128556094383</guid><pubDate>Wed, 01 Feb 2012 12:13:00 +0000</pubDate><atom:updated>2012-02-11T06:26:51.342+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Javascript</category><category domain="http://www.blogger.com/atom/ns#">MS CRM 2011</category><title>Insert New Record In Micosoft CRM 2011 Using oData Call</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Problem:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Need to insert new record from the JavaScript by using the oData call in Microsoft CRM 2011.
&lt;/div&gt;
&lt;b&gt;Solution:&lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The solution of the above problem is very simple and you can find the solution in the Microsoft CRM 2011 SDK as well. In Microsoft CRM 2011 SDK you can find separate file which contain all the function like Create, Update&amp;nbsp; and delete record using oData which you can reuse. But in this post I will use oData call without using the help JavaScript file.
The JavaScript code is listed in the &lt;i&gt;List 1&lt;/i&gt;. In the code you can see that I have created addAccountRecord object and then assigned appropriate value to some of the property of the object.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;b&gt;Note:&lt;/b&gt; You can use the Schema Name of the attribute as you can see in the Image 1, here you can see that PrimaryContactId is used to set the Primary Contact of the account.&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEPPJcdF4bVlrI4d9HifESpnK4NFT69mPW34w2NA3U99zyz52ZFvMPuHKUo5p47zR5DmJFBXTRag5D_tU9KAf5OpZtwqtmPDAvMKAq_beXsbUkpLbg4DFTwjKs5n0NO5e0_ey84hzVExc/s1600/2-5-2012+1-06-00+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="237" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEPPJcdF4bVlrI4d9HifESpnK4NFT69mPW34w2NA3U99zyz52ZFvMPuHKUo5p47zR5DmJFBXTRag5D_tU9KAf5OpZtwqtmPDAvMKAq_beXsbUkpLbg4DFTwjKs5n0NO5e0_ey84hzVExc/s400/2-5-2012+1-06-00+PM.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 1&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Similarly I have other attribute of the account entity like Name, Description, 
Revenue , DoNotPhone etc, you can use the name from the schema name from the attribute list of the entity. In the JavaScript code listed in &lt;i&gt;List 1&lt;/i&gt; you can see that Name and the Description attribute are of type Text mean you can assign simple string value to these two attribute.&lt;br /&gt;
The PrimaryContactId which is lookup type of contact entity , you have to provide the object which has the Id of the contact , LogicalName of the entity which in this case will be the contact entity and the name of the contact which "Susan Burk (Sample)" in this case. So in order to set the value for a lookup field of the account you have to provide Id , logical name and name.Here I have get the Id of the contact by using the developer toolbar to inspect the HTML of the active account grid so that I can assign value to the lookup field you may use different technique to get the Id and name of the contact.&lt;br /&gt;
Next is how to set the value to the picklist and the currency. If you have created plugin then you have idea how to set the value to the picklist and the currency attribute. You need to set the Value of the picklist and currency type and here in the code you can see that I have used that value to set the value to of picklist and the currency type. Last is how to set the value of the boolean type it is just simple either set true of false the only value for the boolean type.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;script class="brush: javascript " type="syntaxhighlighter"&gt;
&lt;![CDATA[
function CreateAccount() {
    var ODataPath = Xrm.Page.context.getServerUrl() + "/XRMServices/2011/OrganizationData.svc";

    var addAccountRecord = {};
    addAccountRecord.Name = "Account Full Name";
    addAccountRecord.Description = "This account was created by the JavaScript using oData Call.";

    //Set a lookup value
    addAccountRecord.PrimaryContactId = { Id: '{8AB3406F-1A4F-E111-8D42-1CC1DEE89A5C}', LogicalName: "contact", Name: 'Susan Burk (sample)' };

    //Set a picklist value
    addAccountRecord.PreferredContactMethodCode = { Value: 2 }; //E-mail

    //Set a money value
    addAccountRecord.Revenue = { Value: "2000000.00" }; //Set Annual Revenue

    //Set a Boolean value
    addAccountRecord.DoNotPhone = true; //Do Not Allow

    var createNewAccount = new XMLHttpRequest();
    createNewAccount.open("POST", ODataPath + "/AccountSet", true);
    createNewAccount.setRequestHeader("Accept", "application/json");
    createNewAccount.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    createNewAccount.onreadystatechange = function () {
        onAccountCreateCallBack(this);
    };
    createNewAccount.send(JSON.stringify(addAccountRecord));

}

function onAccountCreateCallBack(createAccountReturnValue) {
    if (createAccountReturnValue.readyState == 4 /* complete */) {
        if (createAccountReturnValue.status == 201) {
            var createAccountReturnValue = JSON.parse(createAccountReturnValue.responseText).d;
            if (createAccountReturnValue != null) {
                if (createAccountReturnValue.Name != null) {
                    alert("Retrieved the account named \"" + createAccountReturnValue.Name + "\". This account was created on : \"" + createAccountReturnValue.CreatedOn + "\".");
                }
            }
        }
        else
            alert("Error occured while inserting new record.");
    }
}
]]&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 1&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Next point which I would like to mention here is the how the XMLHttpRequest object is open as I am sending data to the server mean to submit in the sever to I will use "POST", here you can notice that if we need to get data from the server we use "GET" but as you know we are inserting record in the database so we use "POST". Next is the URL which is appended with the "AccountSet" which is the name of the entity "Account". Last parameter for the open function is the boolean value to indicate whether we are making async or sync call by passing true we indicate that we are making async call if you pass false then call weill be sync.&lt;br /&gt;
In XMLHttpRequest object send function we pass the object by calling JSON.stringify function which is use to converting JavaScript data structures into JSON text. In the "onAccountCreateCallBack" event handler we check for the readyState of the passed object and status of the object. Here you can see that in this case it will return 201 if record is inserted successfully in the database.
&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMjmyJk3DRB-c9aT8i2jWQt3qXETI-Cg02zQ5a4Kf_BmZ-qaMkejjAP-3A7H1vXxU6TE0QsVVcHeLpDpLAmbrS93WGo52k4cUPcBX-rgarbXa1LO8bY5fmtpgG0d-N34NCeTXQh-ZCvCI/s1600/2-5-2012+12-07-28+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="79" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMjmyJk3DRB-c9aT8i2jWQt3qXETI-Cg02zQ5a4Kf_BmZ-qaMkejjAP-3A7H1vXxU6TE0QsVVcHeLpDpLAmbrS93WGo52k4cUPcBX-rgarbXa1LO8bY5fmtpgG0d-N34NCeTXQh-ZCvCI/s400/2-5-2012+12-07-28+PM.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image2&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;
It will return whole record of the account which is just added in the database. I have only used the Name and the Creation date to be shown that record is added in the database. As you can see in the above image &lt;i&gt;Image 2&lt;/i&gt;. You can see the newly added record in the active account view which is shown in the &lt;i&gt;Image 3&lt;/i&gt; as below.
&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfbj-0OqMRCqp2Hmankw6k4N2vW-1BEbQdQBdX6TROlZX-CU066nE6RyuZtQ-2o-P7fnzTYcoa0OtjFPI95kxCZZ2FuoGH1m5zMGytLnbEAf_8PFHndkxoyg40tkUX9BGUMoDZ7Afdo88/s1600/2-5-2012+12-00-07+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="199" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfbj-0OqMRCqp2Hmankw6k4N2vW-1BEbQdQBdX6TROlZX-CU066nE6RyuZtQ-2o-P7fnzTYcoa0OtjFPI95kxCZZ2FuoGH1m5zMGytLnbEAf_8PFHndkxoyg40tkUX9BGUMoDZ7Afdo88/s400/2-5-2012+12-00-07+PM.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image3&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style="text-align: justify;"&gt;
You just need one extra resource JSON2 which you can get from &lt;a href="https://github.com/douglascrockford/JSON-js/blob/master/json2.js"&gt;here&lt;/a&gt;. Just add the JSON2 as web resource and add that web resource in the form reference so that it can be accessible when you refere it. Just click the "From properties" by opening the form from customization and you will see the dialog as shown in the &lt;i&gt;Image 4&lt;/i&gt; and here you have to add the JSON2 web resource to access in the form.
&lt;br /&gt;
&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVJupNupitIZTQQNZhUWioDiPqSR4kPJ9rsdNZ2JYQ8N3SAT6LHkw8_mdQyfI4W_afjiR33FmVq4vuVdTaPa4WKN9WE-k4BFvKrmINNOqLWuQAUlDcN5q6Wmhvm1enSthRBGlnaGlC3vk/s1600/Account+Form.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="384" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVJupNupitIZTQQNZhUWioDiPqSR4kPJ9rsdNZ2JYQ8N3SAT6LHkw8_mdQyfI4W_afjiR33FmVq4vuVdTaPa4WKN9WE-k4BFvKrmINNOqLWuQAUlDcN5q6Wmhvm1enSthRBGlnaGlC3vk/s400/Account+Form.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;strong&gt;Image 4&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;Hope you get some idea of how to add the record using JavaScript and odata call. I have call above JavaScript on load of form so that when form is loaded new record will be created and alert will be shown which display name of the account and created time of the record.&lt;br /&gt;
&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;All and any comments / bugs /  suggestions are welcomed!&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;</description><link>http://asimsajjad.blogspot.com/2012/02/insert-new-record-in-micosoft-crm-2011.html</link><author>noreply@blogger.com (Asim Sajjad)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEPPJcdF4bVlrI4d9HifESpnK4NFT69mPW34w2NA3U99zyz52ZFvMPuHKUo5p47zR5DmJFBXTRag5D_tU9KAf5OpZtwqtmPDAvMKAq_beXsbUkpLbg4DFTwjKs5n0NO5e0_ey84hzVExc/s72-c/2-5-2012+1-06-00+PM.png" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5765821788458763196.post-3395377555665434443</guid><pubDate>Sun, 22 Jan 2012 07:57:00 +0000</pubDate><atom:updated>2012-01-22T12:57:48.335+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">SilverLight</category><title>Silverlight RichTextBox Scrolling Problem</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;b&gt;Problem: &lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; When assigning value to the RichTextBox and there is larger text and vertical scrolling of the control display then it will scroll to bottom instead of scroll bar to top which need to fix. Which you can see in the &lt;i&gt;Image 1&lt;/i&gt;.&lt;/div&gt;
&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRjkL2QKCsxeX_WLLXSK9vgrhHBE29RcWyon3gEXfEi7bblCasMP1MkyUc4RhMb_zPwP4fCHb1XJs5YatsdTlXYXnPsR6NBgULHI9RMiaxwAUbl8cIok5nXWSFH0uCjtDV3Kg2EonBdzU/s1600/1-22-2012+12-17-41+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="223" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRjkL2QKCsxeX_WLLXSK9vgrhHBE29RcWyon3gEXfEi7bblCasMP1MkyUc4RhMb_zPwP4fCHb1XJs5YatsdTlXYXnPsR6NBgULHI9RMiaxwAUbl8cIok5nXWSFH0uCjtDV3Kg2EonBdzU/s400/1-22-2012+12-17-41+PM.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 1&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;b&gt;Solution: &lt;/b&gt;&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The solution to the above mentioned problem is very easy as when used the RichTextBox control for my one of application I also see this problem and have to fix the problem as it is not good that control go to the bottom of the text instead of showing the start of the text. I have use same example code from my last post "&lt;a href="http://asimsajjad.blogspot.com/2012/01/silverlight-richtextbox-control-for.html" target="_blank"&gt;Silverlight RichTextBox Control For Beginners&lt;/a&gt; " Just modified the layout of the page so that both the RichTextBox binding string and Xaml property of the RichTextBox have vertical scroll bars.The modified code of the property changed event of the view model is listed in &lt;i&gt;List 1&lt;/i&gt; here&amp;nbsp; you can see that I have used the ContentStart property of the RichTextBox control to get the start of the content of the RichTextBox control.&lt;/div&gt;
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
&lt;![CDATA[
        void Home_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "RichTextBoxXAML")
            {
                rtbRichTextBox.Xaml = (DataContext as HomeViewModel).RichTextBoxXAML;
                TextPointer startTextPointer= rtbRichTextBox.ContentStart;
                rtbRichTextBox.Selection.Select(startTextPointer, startTextPointer);
            }
        }
]]&gt;
&lt;/script&gt;
&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;List 1&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
The ContentStart are stored in the TextPointer and then in the next statement I have used the Selection.Select by providing the start pointer to the selection and it will move at the start of the content of the RichTextBox.You can see the output in the &lt;i&gt;Image 2&lt;/i&gt; where you can see that first RichTextBox is scrolled at bottom but the second on is scrolled at top which we want to achieved. &lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2JoSU2JqFmEDS4mUAIfh1vJM9FPH3HoIV_Et5fLD5Q_wYtX9pp5louniTYdD-LxxhECgQ2i0QQ5KOvkanfdjQgt6flmziy_I6Gh3g9fVzH8TbmRJUgwAparGvaC_FyEm4ujes4cxiE_U/s1600/Final.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2JoSU2JqFmEDS4mUAIfh1vJM9FPH3HoIV_Et5fLD5Q_wYtX9pp5louniTYdD-LxxhECgQ2i0QQ5KOvkanfdjQgt6flmziy_I6Gh3g9fVzH8TbmRJUgwAparGvaC_FyEm4ujes4cxiE_U/s400/Final.png" width="367" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;b&gt;Image 2&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
As I have mentioned in my post that I have used the sample of my last post "&lt;a href="http://asimsajjad.blogspot.com/2012/01/silverlight-richtextbox-control-for.html" target="_blank"&gt;Silverlight RichTextBox Control For Beginners&lt;/a&gt; " , So you can get source code from above link and test the code which I have listed in &lt;i&gt;List 1&lt;/i&gt;&amp;nbsp; and you have to made some GUI modification as well so that both the RichTextBox control have the vertical scroll bars.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: Segoe UI;"&gt;&lt;b&gt;All and any comments / bugs /  suggestions are welcomed!&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;</description><link>http://asimsajjad.blogspot.com/2012/01/silverlight-richtextbox-scrolling.html</link><author>noreply@blogger.com (Asim Sajjad)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRjkL2QKCsxeX_WLLXSK9vgrhHBE29RcWyon3gEXfEi7bblCasMP1MkyUc4RhMb_zPwP4fCHb1XJs5YatsdTlXYXnPsR6NBgULHI9RMiaxwAUbl8cIok5nXWSFH0uCjtDV3Kg2EonBdzU/s72-c/1-22-2012+12-17-41+PM.png" width="72"/><thr:total>1</thr:total></item></channel></rss>