<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.falafel.com/~d/styles/itemcontent.css"?><rss xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
  <channel>
    <title>Falafel Blog Feed</title>
    <description>The Falafel Software Blogs Feed</description>
    <link>http://blog.falafel.com/Blogs.aspx</link>
    <docs>http://backend.userland.com/rss</docs>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.falafel.com/FalafelBlogs" /><feedburner:info uri="falafelblogs" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><geo:lat>37.213624</geo:lat><geo:long>-121.856713</geo:long><item>
      <title>Project Houston</title>
      <description>&lt;p&gt;I came across a neat Utility, codename Project Houston. It is a web based SQLAzure admin tool, that allows you to work with SqlAzure databases much as you would with SQL Server Management Studio (SSMS) and regular SQL Server databases.&lt;/p&gt;  &lt;p&gt;It is a CTP right now and can be found here: &lt;a href="https://www.sqlazurelabs.com/houston.aspx"&gt;https://www.sqlazurelabs.com/houston.aspx&lt;/a&gt;. I found it pretty handy.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-ProjectHouston_136ED-image_2.sflb.ashx"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-ProjectHouston_136ED-image_thumb.sflb.ashx" width="688" height="434" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Houston, we do not have a problem! &lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=A17l9TDPeFE:8unKYNZAgm8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=A17l9TDPeFE:8unKYNZAgm8:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=A17l9TDPeFE:8unKYNZAgm8:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?i=A17l9TDPeFE:8unKYNZAgm8:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=A17l9TDPeFE:8unKYNZAgm8:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FalafelBlogs/~4/A17l9TDPeFE" height="1" width="1"/&gt;</description>
      <link>http://feeds.falafel.com/~r/FalafelBlogs/~3/A17l9TDPeFE/Project_Houston.aspx</link>
      <author>John Waters</author>
      <comments>http://blog.falafel.com/Blogs/10-09-05/Project_Houston.aspx</comments>
      <guid isPermaLink="false">d2b4ab4f-636a-4404-bfc9-6bf2667dfae6</guid>
      <pubDate>Mon, 06 Sep 2010 05:07:35 GMT</pubDate>
    <feedburner:origLink>http://blog.falafel.com/Blogs/10-09-05/Project_Houston.aspx</feedburner:origLink></item>
    <item>
      <title>Migrating Data to SqlAzure</title>
      <description>&lt;p&gt;In the midst of figuring out SqlAzure, I found a handy &lt;a href="http://blogs.msdn.com/b/sqlazure/archive/2010/05/17/10014014.aspx" target="_blank"&gt;article&lt;/a&gt; showing how to export data from a regular SQL Server database into you SQLAzure database.&lt;/p&gt;  &lt;p&gt;I had already created the SQLAzure DB, and the tables (I just generated scripts from my original database, and ran them from SQL Server Management Studio (SSMS) 2008 RS (note, you need R2 to work with Azure), until they passed with no errors. I had to get rid of most of the options in the WITH statement, and the [PRIMARY] designations below:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; &lt;span class="kwrd"&gt;TABLE&lt;/span&gt; [dbo].[ConferenceInfos](
    [Id] [&lt;span class="kwrd"&gt;int&lt;/span&gt;] &lt;span class="kwrd"&gt;IDENTITY&lt;/span&gt;(1,1) &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [Name] [nvarchar](&lt;span class="kwrd"&gt;max&lt;/span&gt;) &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [StartDate] [datetime] &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [EndDate] [datetime] &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [Location] [nvarchar](&lt;span class="kwrd"&gt;max&lt;/span&gt;) &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [Logo] [nvarchar](&lt;span class="kwrd"&gt;max&lt;/span&gt;) &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [Published] [&lt;span class="kwrd"&gt;bit&lt;/span&gt;] &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [MinViewerVersion] [nvarchar](&lt;span class="kwrd"&gt;max&lt;/span&gt;) &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
    [Config] [nvarchar](&lt;span class="kwrd"&gt;max&lt;/span&gt;) &lt;span class="kwrd"&gt;NOT&lt;/span&gt; &lt;span class="kwrd"&gt;NULL&lt;/span&gt;,
 &lt;span class="kwrd"&gt;CONSTRAINT&lt;/span&gt; [PK_ConferenceInfos] &lt;span class="kwrd"&gt;PRIMARY&lt;/span&gt; &lt;span class="kwrd"&gt;KEY&lt;/span&gt; &lt;span class="kwrd"&gt;CLUSTERED&lt;/span&gt; 
(
    [Id] &lt;span class="kwrd"&gt;ASC&lt;/span&gt;
)&lt;span class="kwrd"&gt;WITH&lt;/span&gt; (PAD_INDEX  = &lt;span class="kwrd"&gt;OFF&lt;/span&gt;, STATISTICS_NORECOMPUTE  = &lt;span class="kwrd"&gt;OFF&lt;/span&gt;, IGNORE_DUP_KEY = &lt;span class="kwrd"&gt;OFF&lt;/span&gt;, ALLOW_ROW_LOCKS  = &lt;span class="kwrd"&gt;ON&lt;/span&gt;, ALLOW_PAGE_LOCKS  = &lt;span class="kwrd"&gt;ON&lt;/span&gt;) &lt;span class="kwrd"&gt;ON&lt;/span&gt; [&lt;span class="kwrd"&gt;PRIMARY&lt;/span&gt;]
) &lt;span class="kwrd"&gt;ON&lt;/span&gt; [&lt;span class="kwrd"&gt;PRIMARY&lt;/span&gt;]
&lt;span class="kwrd"&gt;GO&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/p&gt;

&lt;p&gt;The actual transfer was done by right clicking my original database, Tasks, Export Data. The trick is in step 2 of the wizard, when you chose the destination, you can NOT use SQL Server Native Client 10.0. Instead, choose “.NET Framework Data Provider for SqlServer”, and fill out the following items:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;UserID – a user in your SqlAzure database that has sufficient rights&lt;/li&gt;

  &lt;li&gt;Password – the password&lt;/li&gt;

  &lt;li&gt;Data Source: the name of your SQLAzure instance&lt;/li&gt;

  &lt;li&gt;Initial Catalog – the name of your database&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-MigratingDatatoSqlAzure_12F32-image_4.sflb.ashx"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-MigratingDatatoSqlAzure_12F32-image_thumb_1.sflb.ashx" width="420" height="432" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;The rest is just as normal and it works like a charm! Happy migrating&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=u4C9VW6FQs4:7_BF5eylKlY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=u4C9VW6FQs4:7_BF5eylKlY:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=u4C9VW6FQs4:7_BF5eylKlY:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?i=u4C9VW6FQs4:7_BF5eylKlY:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=u4C9VW6FQs4:7_BF5eylKlY:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FalafelBlogs/~4/u4C9VW6FQs4" height="1" width="1"/&gt;</description>
      <link>http://feeds.falafel.com/~r/FalafelBlogs/~3/u4C9VW6FQs4/Migrating_Data_to_SqlAzure.aspx</link>
      <author>John Waters</author>
      <comments>http://blog.falafel.com/Blogs/10-09-05/Migrating_Data_to_SqlAzure.aspx</comments>
      <guid isPermaLink="false">987bbb6e-6b06-4237-b039-d3e247fc708d</guid>
      <pubDate>Mon, 06 Sep 2010 04:34:35 GMT</pubDate>
    <feedburner:origLink>http://blog.falafel.com/Blogs/10-09-05/Migrating_Data_to_SqlAzure.aspx</feedburner:origLink></item>
    <item>
      <title>Our Journey to the Cloud Begins</title>
      <description>&lt;p&gt;Today, we embarked on our journey into the Cloud, more specifically the Windows Azure Cloud. This journey goes hand in hand with our venture into the Mobile market. Mobile apps and Cloud services make a perfect match. The devices roam across the face of the planet, running a variety of Operating Systems, from the Apple iPhone and iPad devices in all their incarnations, to the slew of Android machines hitting the market, and now the upcoming Windows Phones.&lt;/p&gt;  &lt;p&gt;Falafel Software is writing software for all these environments, and now we are also writing services for them as well. We will be providing a range of services to support our mobile offerings, including SQL Azure for database storage, REST WCF services, BLOB file storage in the Cloud, and Notifications.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=QhguqYDyI30:GVgoDZv2Lns:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=QhguqYDyI30:GVgoDZv2Lns:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=QhguqYDyI30:GVgoDZv2Lns:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?i=QhguqYDyI30:GVgoDZv2Lns:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=QhguqYDyI30:GVgoDZv2Lns:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FalafelBlogs/~4/QhguqYDyI30" height="1" width="1"/&gt;</description>
      <link>http://feeds.falafel.com/~r/FalafelBlogs/~3/QhguqYDyI30/Our_Journey_to_the_Cloud_Begins.aspx</link>
      <author>John Waters</author>
      <comments>http://blog.falafel.com/Blogs/10-09-05/Our_Journey_to_the_Cloud_Begins.aspx</comments>
      <guid isPermaLink="false">f2672239-060b-419a-8473-a88d61000b89</guid>
      <pubDate>Mon, 06 Sep 2010 03:29:45 GMT</pubDate>
    <feedburner:origLink>http://blog.falafel.com/Blogs/10-09-05/Our_Journey_to_the_Cloud_Begins.aspx</feedburner:origLink></item>
    <item>
      <title>MonoDroid Videos</title>
      <description>&lt;table border="0" cellspacing="0" cellpadding="2" width="600"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top" style="width: 400px;"&gt;Falafel Software created &lt;a href="http://tv.falafel.com/IPhone.aspx?BlogTagID=f6392bb4-99b5-452e-b262-27341c7bc146"&gt;two videos&lt;/a&gt; on the pre-release version of &lt;a href="http://www.monodroid.net"&gt;MonoDroid&lt;/a&gt; in the last week with permission from the Mono Development Team at Novell in order to demonstrate the power of this upcoming tool in building Android Applications in Visual Studio 2010 using C#.&amp;nbsp;&amp;nbsp; &lt;br /&gt;
            The first video was downloaded 12,000 times in the first 36 hours worldwide.&amp;nbsp; The interest is very high for this tool!          &lt;br /&gt;
            What do you think of the ability to write C# code for the Android SDK?&lt;/td&gt; &lt;td valign="top" style="width: 200px;"&gt;&lt;a href="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-MonoDroidVideos_F7C3-image_4.sflb.ashx"&gt;&lt;img style="border: 0px;  display: inline;" title="image" alt="image" src="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-MonoDroidVideos_F7C3-image_thumb_1.sflb.ashx" width="196" height="105" /&gt;&lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=pwM6t9gDv1M:lfgnVnKT6sY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=pwM6t9gDv1M:lfgnVnKT6sY:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=pwM6t9gDv1M:lfgnVnKT6sY:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?i=pwM6t9gDv1M:lfgnVnKT6sY:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=pwM6t9gDv1M:lfgnVnKT6sY:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FalafelBlogs/~4/pwM6t9gDv1M" height="1" width="1"/&gt;</description>
      <link>http://feeds.falafel.com/~r/FalafelBlogs/~3/pwM6t9gDv1M/MonoDroid_Videos.aspx</link>
      <author>Lino Tadros</author>
      <comments>http://blog.falafel.com/Blogs/10-08-25/MonoDroid_Videos.aspx</comments>
      <guid isPermaLink="false">494790ff-926d-48d8-859a-468d6452bd18</guid>
      <pubDate>Thu, 26 Aug 2010 00:00:00 GMT</pubDate>
    <feedburner:origLink>http://blog.falafel.com/Blogs/10-08-25/MonoDroid_Videos.aspx</feedburner:origLink></item>
    <item>
      <title>Binding Tab Navigation to a Control&amp;rsquo;s Enabled State in Silverlight</title>
      <description>&lt;p&gt;I got some positive feedback on my recent post about &lt;a href="http://blog.falafel.com/blogs/jonathantower/10-07-29/Binding_a_TextBlock_rsquo_s_ToolTip_to_its_Own_Text_Property_in_Silverlight.aspx"&gt;binding a TextBlock’s tooltip to its own text property&lt;/a&gt;, so I decided to post this related follow-up…&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Allowing your users to navigate your forms with the keyboard is a very important usability feature that is often overlooked.&amp;nbsp; In Silverlight, this is accomplished by setting IsTabStop to True on any controls you want to participate in keyboard navigation.&amp;nbsp; When the user hits the tab key, focus will cycle through all the controls where IsTabStop is True, one at a time.&amp;nbsp; Any controls where IsTabStop is false will be skipped.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;One problem I’ve often run into in Silverlight is making sure that keyboard navigation only sets the focus on &lt;span style="text-decoration: underline;"&gt;active&lt;/span&gt; controls.&amp;nbsp; For example, consider a form with a Save button that is disabled until all the required fields have been filled in.&amp;nbsp; If the user forgets to fill in a required field and tabs past the last field on the form (assuming the Save button is at the bottom of the form), focus will move to the still-disabled Save button.&amp;nbsp; It may be very difficult for the user to see what happened to the focus.&amp;nbsp; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;In lieu solving this by writing code in the code-behind that sets IsTabStop whenever there is a change to the button’s IsEnabled property, I recommend using Silverlight’s build-in binding capabilities to&amp;nbsp; “set it and forget it”.&amp;nbsp; From then on, any changes you make that enable or disable the Save button will also enable or disable tab navigation for the control.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Without further ado, here’s the code to accomplish this:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9752f05a-faae-4cab-841c-17abf0369d7f" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px  solid  #000080;color: #000000; font-family: 'courier new', courier, monospace; font-size: 10pt;"&gt; &lt;div style="background-color: #f8f8f8; max-height: 500px; overflow-x: auto; overflow-y: auto; padding-top: 2px; padding-right: 5px; padding-bottom: 2px; padding-left: 5px; white-space: nowrap;"&gt;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Button&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; x&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="btnSave"&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Width&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="80"&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Content&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="Save"&lt;/span&gt; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000;"&gt;IsTabStop&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Path&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;=IsEnabled,&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; RelativeSource&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;={&lt;/span&gt;&lt;span style="color: #a31515;"&gt;RelativeSource&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Self}}&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;" /&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt; &lt;br /&gt;
To take it one step further, instead of copying this binding into every button make a UserControl or global Style for your buttons that implements this binding by default and use that UserControl or Style throughout your application.&amp;nbsp; Then all your buttons will have this feature without having to remember to implement it every time.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=ioxBgTVfSes:t0AOYZWUxzk:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=ioxBgTVfSes:t0AOYZWUxzk:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=ioxBgTVfSes:t0AOYZWUxzk:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?i=ioxBgTVfSes:t0AOYZWUxzk:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=ioxBgTVfSes:t0AOYZWUxzk:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FalafelBlogs/~4/ioxBgTVfSes" height="1" width="1"/&gt;</description>
      <link>http://feeds.falafel.com/~r/FalafelBlogs/~3/ioxBgTVfSes/Binding_Tab_Navigation_to_a_Control_rsquo_s_Enabled_State_in_Silverlight.aspx</link>
      <author>J. Tower</author>
      <comments>http://blog.falafel.com/Blogs/10-08-23/Binding_Tab_Navigation_to_a_Control_rsquo_s_Enabled_State_in_Silverlight.aspx</comments>
      <guid isPermaLink="false">32d91e8f-13f2-4369-aa02-5c0d3d413e9c</guid>
      <pubDate>Mon, 23 Aug 2010 14:31:21 GMT</pubDate>
    <feedburner:origLink>http://blog.falafel.com/Blogs/10-08-23/Binding_Tab_Navigation_to_a_Control_rsquo_s_Enabled_State_in_Silverlight.aspx</feedburner:origLink></item>
    <item>
      <title>Automate Common Tasks With Batch Files</title>
      <description>&lt;p&gt;I know, you are probably thinking “Batch files? What is this, the Dark Age of DOS?” Bear with me; while you might see batch files as antiquated relics, I have come to see them as simple and elegant tools (with admittedly primitive syntax) that speed my daily development. They seem to have become a bit of a lost art in this day and age of point-and-click UIs. Let me share a few scenarios with you.&lt;/p&gt; &lt;h1&gt;Delete log files before running an app&lt;/h1&gt; &lt;p&gt;This one is simple. I am on a team developing a large WCF multi-tier application with plenty of logging happening. If I am really only interested in the log output from my latest run, I don’t want to have to scroll past all of the old entries. Besides, some of the WCF *.svclog files can grow pretty big.&lt;/p&gt; &lt;pre class="csharpcode"&gt;del *log
start app.exe&lt;/pre&gt; &lt;style type="text/css"&gt;
    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }
&lt;/style&gt; &lt;p&gt;This simple batch file first deletes all files ending with “log” (so, *.log and *.svclog) in the current directory, launches app.exe, and then closes the command window.&lt;/p&gt; &lt;h1&gt;Start a web app in a non-default browser&lt;/h1&gt; &lt;p&gt;I don’t have Internet Explorer set as my default browser, but I want to use it to run a web app.&lt;/p&gt; &lt;pre class="csharpcode"&gt;start &lt;span class="str"&gt;""&lt;/span&gt; &lt;span class="str"&gt;"C:\Program Files (x86)\Internet Explorer\iexplore.exe"&lt;/span&gt; &lt;span class="str"&gt;"http://virtual_dir/start_page.aspx"&lt;/span&gt;&lt;/pre&gt; &lt;style type="text/css"&gt;
    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }
&lt;/style&gt; &lt;p&gt;The first empty string is for the “optional” (according to the documentation) title, but if it is omitted, the start command will not work in this case.&lt;/p&gt; &lt;h1&gt;Drop and rebuild a DB with multiple SQL scripts&lt;/h1&gt; &lt;p&gt;In our current project, we rebuild our DBs from scratch often, and it takes multiple steps to do so. All of these manual steps have been automated by a batch file.&lt;/p&gt; &lt;pre class="csharpcode"&gt;set SQLCMDUSER=user
@set SQLCMDPASSWORD=password
set SQLCMDDBNAME=db

sqlcmd -d master -i &lt;span class="str"&gt;"DropCreate.sql"&lt;/span&gt;
sqlcmd -i &lt;span class="str"&gt;"aspnet_objects.sql"&lt;/span&gt;,&lt;span class="str"&gt;"app_objects.sql"&lt;/span&gt; &lt;span class="str"&gt;"path\populate_data.exe"&lt;/span&gt; params
type &lt;span class="str"&gt;"path\populate_data.log"&lt;/span&gt;&lt;/pre&gt; &lt;style type="text/css"&gt;
    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }
&lt;/style&gt; &lt;p&gt;The three SET commands set environment variables used by sqlcmd.exe, which is MSSQL’s command-line SQL command executor. The first sqlcmd executes a script that runs in the master DB and drops and re-creates the existing DB and adds a user login. The second sqlcmd executes a script that creates objects for asp.net membership, and then a script that creates our custom objects for our app. The last pair of lines executes a custom tool that loads the fresh DB with initial data and outputs the app’s log file to the command line for review. This batch file has been a huge time-saver for the team, turning a once highly interactive process into an unattended one.&lt;/p&gt; &lt;p&gt;Here is the contents of the DropCreate script, since anyone could find a use for it:&lt;/p&gt; &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;if&lt;/span&gt; &lt;span class="kwrd"&gt;exists&lt;/span&gt; ( &lt;span class="kwrd"&gt;select&lt;/span&gt; * &lt;span class="kwrd"&gt;from&lt;/span&gt; sys.databases &lt;span class="kwrd"&gt;where&lt;/span&gt; name = &lt;span class="str"&gt;'db_name'&lt;/span&gt; )
&lt;span class="kwrd"&gt;begin&lt;/span&gt; &lt;span class="kwrd"&gt;alter&lt;/span&gt; &lt;span class="kwrd"&gt;database&lt;/span&gt; db_name &lt;span class="kwrd"&gt;set&lt;/span&gt; read_only &lt;span class="kwrd"&gt;with&lt;/span&gt; &lt;span class="kwrd"&gt;rollback&lt;/span&gt; &lt;span class="kwrd"&gt;immediate&lt;/span&gt; &lt;span class="kwrd"&gt;drop&lt;/span&gt; &lt;span class="kwrd"&gt;database&lt;/span&gt; db_name
&lt;span class="kwrd"&gt;end&lt;/span&gt; &lt;span class="kwrd"&gt;go&lt;/span&gt; &lt;span class="kwrd"&gt;create&lt;/span&gt; &lt;span class="kwrd"&gt;database&lt;/span&gt; db_name
&lt;span class="kwrd"&gt;go&lt;/span&gt; &lt;span class="kwrd"&gt;use&lt;/span&gt; db_name
&lt;span class="kwrd"&gt;go&lt;/span&gt; &lt;span class="kwrd"&gt;create&lt;/span&gt; &lt;span class="kwrd"&gt;user&lt;/span&gt; user_name
&lt;span class="kwrd"&gt;go&lt;/span&gt; &lt;span class="kwrd"&gt;exec&lt;/span&gt; sp_addrolemember &lt;span class="str"&gt;'db_owner'&lt;/span&gt;, &lt;span class="str"&gt;'user_name'&lt;/span&gt;
go&lt;/pre&gt; &lt;style type="text/css"&gt;
    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }
&lt;/style&gt; &lt;p&gt;To adapt it to your purposes, just replace db_name with your DB’s name, and user_name with a user account. The script will terminate any active connections prior to dropping the DB, since any active connections would cause the DROP DATABASE to fail.&lt;/p&gt; &lt;h1&gt;&lt;/h1&gt; &lt;h1&gt;Test a DB upgrade script against multiple DB versions&lt;/h1&gt; &lt;p&gt;Our project has a SQL script that is designed to run against any past deployed DB version and bring that DB to the current version. This can be a complex task, and sometimes a script that works against one version will encounter errors when run against a different version. Here is a solution that I put together to test the latest upgrade script against any past DB that I have a backup of.&lt;/p&gt; &lt;p&gt;First of all, I keep all of the past DB versions backed up in a single .BAK file. Now, I have this SQL script that can restore any of the backups:&lt;/p&gt; &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;use&lt;/span&gt; master
&lt;span class="kwrd"&gt;go&lt;/span&gt; &lt;span class="kwrd"&gt;alter&lt;/span&gt; &lt;span class="kwrd"&gt;database&lt;/span&gt; db_name
&lt;span class="kwrd"&gt;set&lt;/span&gt; read_only
&lt;span class="kwrd"&gt;with&lt;/span&gt; &lt;span class="kwrd"&gt;rollback&lt;/span&gt; &lt;span class="kwrd"&gt;immediate&lt;/span&gt; &lt;span class="kwrd"&gt;GO&lt;/span&gt; &lt;span class="kwrd"&gt;RESTORE&lt;/span&gt; &lt;span class="kwrd"&gt;DATABASE&lt;/span&gt; [db_name] &lt;span class="kwrd"&gt;FROM&lt;/span&gt; &lt;span class="kwrd"&gt;DISK&lt;/span&gt; = N&lt;span class="str"&gt;'path\db_name.bak'&lt;/span&gt; &lt;span class="kwrd"&gt;WITH&lt;/span&gt; REPLACE,  &lt;span class="kwrd"&gt;FILE&lt;/span&gt; = $(&lt;span class="kwrd"&gt;file&lt;/span&gt;),  NOUNLOAD,  STATS = 10
GO&lt;/pre&gt; &lt;style type="text/css"&gt;
    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }
&lt;/style&gt; &lt;p&gt;That $(file) is a substitution variable that will be supplied by the batch file that runs this script. Now, here is the batch script. It loops through all of the backups in the backup file and restores them, and then runs the upgrade script against the restored backup. If the upgrade encounters an error, the script stops and displays the file number of the backup that encountered the error, so that I can start interactively debugging the upgrade script against that DB version.&lt;/p&gt; &lt;pre class="csharpcode"&gt;@echo off
set SQLCMDUSER=sa
set SQLCMDPASSWORD=password
set SQLCMDDBNAME=db_name

&lt;span class="kwrd"&gt;for&lt;/span&gt; /l %%i &lt;span class="kwrd"&gt;in&lt;/span&gt; (1,1,8) do (
    sqlcmd -v file=&lt;span class="str"&gt;"%%i"&lt;/span&gt; -i &lt;span class="str"&gt;"RestoreOld.sql"&lt;/span&gt;
    sqlcmd -b -i &lt;span class="str"&gt;"upgrade_objects.sql"&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; errorlevel 1 (
        echo Error at %%i
        pause
        exit
    )
)
echo Success
pause&lt;/pre&gt; &lt;style type="text/css"&gt;
    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }
&lt;/style&gt; &lt;p&gt;The first line in the FOR loop passes the loop variable’s value into the $(file) substitution variable in the SQL script above, restoring the backup files 1 through 8 in succession. The next line runs the upgrade script, and the last block tests the value of the errorlevel environment variable, which is set by sqlcmd if an error is encountered. &lt;/p&gt; &lt;h1&gt;&lt;/h1&gt; &lt;h1&gt;How to get started for yourself&lt;/h1&gt; &lt;p&gt;I hope by now, you can see how just a few lines in a batch script can automate tasks and save a lot of time and effort. The best way to get started is simply to read the documentation. Just open a command prompt on your system and type “help” to see a list of built-in commands.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=tG_1eVqbZKc:V98DqvpXmME:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=tG_1eVqbZKc:V98DqvpXmME:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=tG_1eVqbZKc:V98DqvpXmME:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?i=tG_1eVqbZKc:V98DqvpXmME:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=tG_1eVqbZKc:V98DqvpXmME:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FalafelBlogs/~4/tG_1eVqbZKc" height="1" width="1"/&gt;</description>
      <link>http://feeds.falafel.com/~r/FalafelBlogs/~3/tG_1eVqbZKc/Automate_Common_Tasks_With_Batch_Files.aspx</link>
      <author>Adam Anderson</author>
      <comments>http://blog.falafel.com/Blogs/10-08-13/Automate_Common_Tasks_With_Batch_Files.aspx</comments>
      <guid isPermaLink="false">eed1b013-1d82-48fb-9805-9f4aba62b6d4</guid>
      <pubDate>Fri, 13 Aug 2010 22:23:32 GMT</pubDate>
    <feedburner:origLink>http://blog.falafel.com/Blogs/10-08-13/Automate_Common_Tasks_With_Batch_Files.aspx</feedburner:origLink></item>
    <item>
      <title>WCF RIA Services Default Load Behavior Can Be Misleading</title>
      <description>&lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin: 0in 0in 10pt;"&gt;Recently I was given a task of creating a quick example of someone making a data change to a database table then someone else being able to see the new data. Seemed simple enough. I created a WCF RIA Services application with a simple grid and submit/refresh buttons&amp;nbsp; on it. I brought up two instances of the application and had one instance change the data and the other refresh it. To my amazement the second instance didn’t see the new data. &lt;/p&gt; &lt;p style="margin: 0in 0in 10pt;"&gt;I brought up SQL Server Profiler to see what was going on. When hitting the refresh button I did see the query getting sent to MSSQL server. I then looked at the result from the load operation in the callback method and I found that for some reason the entities returned were the old copies. I found a solution to this problem to be very simple. Change the load behavior of the load operation.&lt;/p&gt; &lt;p style="margin: 0in 0in 10pt;"&gt;Change this:&lt;/p&gt; &lt;p style="margin: 0in 0in 10pt;"&gt;C#&lt;/p&gt; &lt;div class="reCodeBlock" style="overflow-y: auto;border: #7f9db9 1px solid;"&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;context.Load(context.GetDepartmentsQuery(),&amp;nbsp; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&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;&lt;/code&gt;&lt;span style="margin-left: 39px !important;"&gt;&lt;code style="color: #000;"&gt;Load_Completed, &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;null&lt;/code&gt;&lt;code style="color: #000;"&gt;);&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;VB&lt;/p&gt; &lt;div class="reCodeBlock" style="overflow-y: auto;border: #7f9db9 1px solid;"&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;context.Load(context.GetDepartmentsQuery(), _ &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&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;&lt;/code&gt;&lt;span style="margin-left: 39px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;AddressOf&lt;/code&gt; &lt;code style="color: #000;"&gt;Load_Completed, _ &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&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;&lt;/code&gt;&lt;span style="margin-left: 39px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Nothing&lt;/code&gt;&lt;code style="color: #000;"&gt;) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;To this:&lt;/p&gt; &lt;p&gt;C#&lt;/p&gt; &lt;div class="reCodeBlock" style="overflow-y: auto;border: #7f9db9 1px solid;"&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;context.Load(context.GetDepartmentsQuery(),&amp;nbsp; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&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;&lt;/code&gt;&lt;span style="margin-left: 39px !important;"&gt;&lt;code style="color: #000;"&gt;LoadBehavior.MergeIntoCurrent,&amp;nbsp; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&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;&lt;/code&gt;&lt;span style="margin-left: 39px !important;"&gt;&lt;code style="color: #000;"&gt;Load_Completed, &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;null&lt;/code&gt;&lt;code style="color: #000;"&gt;); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;VB&lt;/p&gt; &lt;div class="reCodeBlock" style="overflow-y: auto;border: #7f9db9 1px solid;"&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;context.Load(context.GetDepartmentsQuery(), _ &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&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;&lt;/code&gt;&lt;span style="margin-left: 39px !important;"&gt;&lt;code style="color: #000;"&gt;LoadBehavior.MergeIntoCurrent, _ &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&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;&lt;/code&gt;&lt;span style="margin-left: 39px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;AddressOf&lt;/code&gt; &lt;code style="color: #000;"&gt;Load_Completed, &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Nothing&lt;/code&gt;&lt;code style="color: #000;"&gt;)&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="line-height: normal; margin: 0in 0in 0pt;"&gt;There are three different load behaviors available:&lt;/p&gt; &lt;ul&gt; &lt;li&gt; &lt;div style="line-height: normal; margin: 0in 0in 0pt;"&gt;Keep Current (default): &amp;nbsp;means that the version that is cached on the client is not changed with the load operation. Entities will not be updated with new information.&lt;/div&gt; &lt;/li&gt; &lt;li&gt; &lt;div style="line-height: normal; margin: 0in 0in 0pt;"&gt;Merge Into Current: &amp;nbsp;if there has been no modification to a cached entity, it will be updated with the load operation entities. This seems to be the safest option if the user will be editing data because the user will not want to lose data they have been entering before a submit.&lt;/div&gt; &lt;/li&gt; &lt;li&gt; &lt;div style="line-height: normal; margin: 0in 0in 0pt;"&gt;Refresh Current: all entities in the cache will be updated with information from the load operation entities. This has the possibility to overwrite a change that the user has made but not committed. Be careful with this option. &lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; &lt;p style="margin: 0in 0in 10pt;"&gt;A sample solution that displays the refresh issue is attached with three projects (ones for C# and VB) that include a test Silverlight client in both languages. This sample uses the AdventureWorks2008 database and logs in with integrated security. Edit the Web.config file if necessary to change the connection string to connect to your database. Steps for using the example are in the sample itself. &lt;a href="http://blog.falafel.com/Files/scottfrolich/LoadOperations.zip" title="VS2010 Three Project Load Operations and Behavior Example Solution"&gt;Load Operations and Behavior Example&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=KPlhyaoWeqw:oDZ-2k5fOHg:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=KPlhyaoWeqw:oDZ-2k5fOHg:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=KPlhyaoWeqw:oDZ-2k5fOHg:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?i=KPlhyaoWeqw:oDZ-2k5fOHg:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=KPlhyaoWeqw:oDZ-2k5fOHg:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FalafelBlogs/~4/KPlhyaoWeqw" height="1" width="1"/&gt;</description>
      <link>http://feeds.falafel.com/~r/FalafelBlogs/~3/KPlhyaoWeqw/WCF_RIA_Services_Default_Load_Behavior_Can_Be_Misleading.aspx</link>
      <author>Scott Frolich</author>
      <comments>http://blog.falafel.com/Blogs/10-08-12/WCF_RIA_Services_Default_Load_Behavior_Can_Be_Misleading.aspx</comments>
      <guid isPermaLink="false">80fb22d3-aca8-4e1b-905e-d1cfd730b82a</guid>
      <pubDate>Thu, 12 Aug 2010 21:43:52 GMT</pubDate>
    <feedburner:origLink>http://blog.falafel.com/Blogs/10-08-12/WCF_RIA_Services_Default_Load_Behavior_Can_Be_Misleading.aspx</feedburner:origLink></item>
    <item>
      <title>BasedOn Styles in Silverlight</title>
      <description>&lt;p&gt;Those that have been programming in WPF for a while probably already know about defining styles based on other styles.&amp;nbsp; With the release of version 3, this feature made the jump over to Silverlight as well.&amp;nbsp; Even though this is old news, as Silverlight is now on version 4, I’ve found that this feature is still little-know, and it’s so useful, I thought it deserved a post.&amp;nbsp; In the post, I’ll go over the basics of how to use this feature for anyone to whom the feature is new.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h2&gt;Why Use BasedOn&lt;/h2&gt; &lt;p&gt;Using BasedOn to define a style allows you to significantly reduce your XAML styling code and improve maintainability.&amp;nbsp; To take advantage of this, you should define base styles in a globally accessible resource dictionary and then define derived styles that only dictate the ways in which they are different from their base styles.&amp;nbsp; For all of us object-oriented programmers, this type of inheritance should feel pretty comfortable!&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h2&gt;Using BasedOn - Step By Step&lt;/h2&gt; &lt;p&gt;To start out with, create a new SIlverlight project and add a StackPanel and four TextBlocks to the MainPage.xaml.&amp;nbsp; Here’s the XAML I used:&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f35fe744-5467-4c6d-bc0c-892b58565246" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px  solid  #000080;color: #000000; font-family: 'courier new', courier, monospace; font-size: 10pt;"&gt; &lt;div style="background-color: #f8f8f8; max-height: 500px; overflow-x: auto; overflow-y: auto; padding-top: 2px; padding-right: 5px; padding-bottom: 2px; padding-left: 5px; white-space: nowrap;"&gt;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;UserControl&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; x&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;Class&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="BasedOnStyles.MainPage"&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000;"&gt; xmlns&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000;"&gt; xmlns&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;x&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000;"&gt; xmlns&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;d&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="http://schemas.microsoft.com/expression/blend/2008"&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000;"&gt; xmlns&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;mc&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="http://schemas.openxmlformats.org/markup-compatibility/2006"&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000;"&gt; mc&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;Ignorable&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="d"&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000;"&gt; d&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;DesignHeight&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="300"&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; d&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;DesignWidth&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="400"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; x&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="LayoutRoot"&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Background&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="White"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;StackPanel&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&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;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="This text is not styled" /&amp;gt;&lt;/span&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;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="This text is not styled" /&amp;gt;&lt;/span&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;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="This text is not styled" /&amp;gt;&lt;/span&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;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="This text is not styled" /&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;StackPanel&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;UserControl&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Now you can create a resource dictionary for your project that will allow you to define styles that can be used throughout your application.&amp;nbsp; I like to put my resource dictionaries in a sub-directory within the project, usually called “ResourceDictionaries” or something similar.&amp;nbsp; Add a new item to the directory by right-clicking and selection Add –&amp;gt; New Item…&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-BasedOnStylesCometoSilveright_C7F7-image_2.sflb.ashx"&gt;&lt;img style="border: 0px;display: inline;" title="image" alt="image" src="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-BasedOnStylesCometoSilveright_C7F7-image_thumb.sflb.ashx" width="645" height="306" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Select “Silverlight Resource Dictionary” and give it a name.&amp;nbsp; In the Resource dictionary, define a style that targets TextBlock tags.&amp;nbsp; Here’s the style I created:&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:8ea88512-e6c8-4e31-841c-7da43845ccab" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px  solid  #000080;color: #000000; font-family: 'courier new', courier, monospace; font-size: 10pt;"&gt; &lt;div style="background-color: #f8f8f8; max-height: 500px; overflow-x: auto; overflow-y: auto; padding-top: 2px; padding-right: 5px; padding-bottom: 2px; padding-left: 5px; white-space: nowrap;"&gt;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;ResourceDictionary&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000;"&gt; xmlns&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000;"&gt; xmlns&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;x&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Style&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; x&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;Key&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="GlobalTextBlockStyle"&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; TargetType&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="TextBlock"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="Foreground"&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="Red"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Style&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;ResourceDictionary&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Now the dictionary needs to be merged into the application’s main dictionary so it will be available globally.&amp;nbsp; Open the App.xaml and update it to look this the code below, replacing “BasedOnStyles” with the name of your Silverlight project and the file path with the path to your resource dictionary file.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1ea0968b-5f2d-4030-a168-65fa2037a6d6" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px  solid  #000080;color: #000000; font-family: 'courier new', courier, monospace; font-size: 10pt;"&gt; &lt;div style="background-color: #f8f8f8; max-height: 500px; overflow-x: auto; overflow-y: auto; padding-top: 2px; padding-right: 5px; padding-bottom: 2px; padding-left: 5px; white-space: nowrap;"&gt;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Application&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; xmlns&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&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;&lt;span style="color: #ff0000;"&gt; xmlns&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;x&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&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;&lt;span style="color: #ff0000;"&gt; x&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;Class&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="BasedOnStyles.App"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Application.Resources&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;ResourceDictionary&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&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;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;ResourceDictionary.MergedDictionaries&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;ResourceDictionary&lt;/span&gt; &lt;br /&gt; &lt;span style="color: #ff0000;"&gt;Source&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="/BasedOnStyles;component/ResourceDictionaries/GlobalStyles.xaml" /&amp;gt;&lt;/span&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;&lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;ResourceDictionary.MergedDictionaries&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;ResourceDictionary&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Application.Resources&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Application&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Now back in MainPage.xaml you can reference your new style as seen in my code example below:&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5f78c5dc-71c7-4f15-a208-6efe74ad5e35" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px  solid  #000080;color: #000000; font-family: 'courier new', courier, monospace; font-size: 10pt;"&gt; &lt;div style="background-color: #f8f8f8; max-height: 500px; overflow-x: auto; overflow-y: auto; padding-top: 2px; padding-right: 5px; padding-bottom: 2px; padding-left: 5px; white-space: nowrap;"&gt;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;UserControl&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; x&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;Class&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="BasedOnStyles.MainPage"&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000;"&gt; xmlns&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000;"&gt; xmlns&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;x&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000;"&gt; xmlns&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;d&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="http://schemas.microsoft.com/expression/blend/2008"&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000;"&gt; xmlns&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;mc&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="http://schemas.openxmlformats.org/markup-compatibility/2006"&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000;"&gt; mc&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;Ignorable&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="d"&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000;"&gt; d&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;DesignHeight&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="300"&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; d&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;DesignWidth&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="400"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; x&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="LayoutRoot"&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Background&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="White"&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Margin&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="10"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;StackPanel&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&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;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="This text is not styled" /&amp;gt;&lt;/span&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;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="This text is styled"&lt;/span&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000;"&gt;Style&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; GlobalTextBlockStyle}&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;" /&amp;gt;&lt;/span&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;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="This text is styled"&lt;/span&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000;"&gt;Style&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; GlobalTextBlockStyle}&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;" /&amp;gt;&lt;/span&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;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="This text is styled"&lt;/span&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000;"&gt;Style&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; GlobalTextBlockStyle}&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;" /&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;StackPanel&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Grid&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;UserControl&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;When you run your project now, it should look something like this:&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-BasedOnStylesCometoSilveright_C7F7-image_4.sflb.ashx"&gt;&lt;img style="border: 0px;display: inline;" title="image" alt="image" src="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-BasedOnStylesCometoSilveright_C7F7-image_thumb_1.sflb.ashx" width="164" height="93" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;br /&gt; &lt;/p&gt; &lt;p&gt;&lt;br /&gt; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Notice that the text in the last three TextBlocks is red now, based on the Foreground color defined by the style you created.&amp;nbsp; That completes the set up work necessary to define global styles.&amp;nbsp; Now you can start creating new styles based on the first one you defined.&amp;nbsp; In the example below, I’ve created two more styles.&amp;nbsp; The second style adds a Bold FontWeight to the first one, and the third style changes the Foreground color AND adds an Italic FontStyle to the second.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b31c5adc-83ff-4242-84a5-5507dc125659" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px  solid  #000080;color: #000000; font-family: 'courier new', courier, monospace; font-size: 10pt;"&gt; &lt;div style="background-color: #f8f8f8; max-height: 500px; overflow-x: auto; overflow-y: auto; padding-top: 2px; padding-right: 5px; padding-bottom: 2px; padding-left: 5px; white-space: nowrap;"&gt;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;ResourceDictionary&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000;"&gt; xmlns&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000;"&gt; xmlns&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;x&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Style&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; x&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;Key&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="GlobalTextBlockStyle"&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; TargetType&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="TextBlock"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="Foreground"&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="Red"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Style&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Style&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; x&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;Key&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="GlobalTextBlockStyle2"&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; TargetType&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="TextBlock"&lt;/span&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000;"&gt; BasedOn&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; GlobalTextBlockStyle}&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="FontWeight"&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="Bold" /&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Style&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Style&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; x&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;Key&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="GlobalTextBlockStyle3"&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; TargetType&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="TextBlock"&lt;/span&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000;"&gt; BasedOn&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; GlobalTextBlockStyle2}&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="Foreground"&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="Orange"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="FontStyle"&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="Italic" /&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Style&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;ResourceDictionary&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Before running your project again, change the style on the last two TextBlocks on MainPage.xaml to reference your new styles.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:304835fe-d2cb-4e9f-818e-85062f1785d1" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px  solid  #000080;color: #000000; font-family: 'courier new', courier, monospace; font-size: 10pt;"&gt; &lt;div style="background-color: #f8f8f8; max-height: 500px; overflow-x: auto; overflow-y: auto; padding-top: 2px; padding-right: 5px; padding-bottom: 2px; padding-left: 5px; white-space: nowrap;"&gt;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="This text is not styled" /&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="This text is styled"&lt;/span&gt; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000;"&gt;Style&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; GlobalTextBlockStyle}&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;" /&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="This text is styled"&lt;/span&gt; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000;"&gt;Style&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; GlobalTextBlockStyle2}&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;" /&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="This text is styled"&lt;/span&gt; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #ff0000;"&gt;Style&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515;"&gt;StaticResource&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; GlobalTextBlockStyle3}&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;" /&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Now when you run your project , every line with have a different style, each one a slight variation to the previous one.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-BasedOnStylesCometoSilveright_C7F7-image_6.sflb.ashx"&gt;&lt;img style="border: 0px;display: inline;" title="image" alt="image" src="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-BasedOnStylesCometoSilveright_C7F7-image_thumb_2.sflb.ashx" width="160" height="103" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;With a set up like this, you are ready for your designer or marketing person to come to you and say, “Can you increase the font size in all the labels throughout the application?”&amp;nbsp; One simple change to your base TextBlock style will do the trick.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2ffada11-ca4b-4b5a-9c10-cf0de9bfc39e" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px  solid  #000080;color: #000000; font-family: 'courier new', courier, monospace; font-size: 10pt;"&gt; &lt;div style="background-color: #f8f8f8; max-height: 500px; overflow-x: auto; overflow-y: auto; padding-top: 2px; padding-right: 5px; padding-bottom: 2px; padding-left: 5px; white-space: nowrap;"&gt;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Style&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; x&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;Key&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="GlobalTextBlockStyle"&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; TargetType&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="TextBlock"&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="Foreground"&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="Red"/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Setter&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Property&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="FontSize"&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Value&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="18"/&amp;gt;&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Style&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&lt;br /&gt; &lt;/p&gt; &lt;p&gt;&lt;br /&gt; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Now all the styled TextBlocks throughout your application get updated with the larger font size.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-BasedOnStylesCometoSilveright_C7F7-image_10.sflb.ashx"&gt;&lt;img style="border: 0px;display: inline;" title="image" alt="image" src="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-BasedOnStylesCometoSilveright_C7F7-image_thumb_4.sflb.ashx" width="224" height="135" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;br /&gt; &lt;/p&gt; &lt;p&gt;&lt;br /&gt; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;I’ve include my &lt;a href="http://blog.falafel.com/Files/JTower/BasedOnStyles.zip"&gt;Silverlight 4 C# project&lt;/a&gt; for you to download and review. &lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=pfSl-gxfkpI:PArp9aY1JBY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=pfSl-gxfkpI:PArp9aY1JBY:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=pfSl-gxfkpI:PArp9aY1JBY:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?i=pfSl-gxfkpI:PArp9aY1JBY:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=pfSl-gxfkpI:PArp9aY1JBY:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FalafelBlogs/~4/pfSl-gxfkpI" height="1" width="1"/&gt;</description>
      <link>http://feeds.falafel.com/~r/FalafelBlogs/~3/pfSl-gxfkpI/BasedOn_Styles_in_Silverlight.aspx</link>
      <author>J. Tower</author>
      <comments>http://blog.falafel.com/Blogs/10-08-12/BasedOn_Styles_in_Silverlight.aspx</comments>
      <guid isPermaLink="false">01ac610f-3311-4313-9da5-15c761824365</guid>
      <pubDate>Thu, 12 Aug 2010 19:46:16 GMT</pubDate>
    <feedburner:origLink>http://blog.falafel.com/Blogs/10-08-12/BasedOn_Styles_in_Silverlight.aspx</feedburner:origLink></item>
    <item>
      <title>Using Primitives with Silverlight Styles</title>
      <description>&lt;p&gt;In every Silverlight project I have worked on I have needed to set some default styles for use throughout the Silverlight controls. So I create a new Silverlight Resource Dictonary and typically add items such as SolidColorBrush:&lt;/p&gt; &lt;div class="reCodeBlock" style="overflow-y: auto;border: #7f9db9 1px solid;"&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;&amp;lt;&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;SolidColorBrush&lt;/code&gt; &lt;code style="color: #808080;"&gt;x:Key&lt;/code&gt;&lt;code style="color: #000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"DefaultForeground"&lt;/code&gt; &lt;code style="color: #808080;"&gt;Color&lt;/code&gt;&lt;code style="color: #000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"#FF1F4386"&lt;/code&gt; &lt;code style="color: #000;"&gt;/&amp;gt; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;&amp;lt;&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;SolidColorBrush&lt;/code&gt; &lt;code style="color: #808080;"&gt;x:Key&lt;/code&gt;&lt;code style="color: #000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"DefaultLabelForeground"&lt;/code&gt; &lt;code style="color: #808080;"&gt;Color&lt;/code&gt;&lt;code style="color: #000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"GreenYellow"&lt;/code&gt; &lt;code style="color: #000;"&gt;/&amp;gt; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin: 0in 0in 10pt;"&gt;It is great to have one place to define styles and for the case above colors of my Silverlight components but then I wanted to set a particular font family and font size. This wasn’t immediately clear to me how to do that because what I needed was a string to represent the font family and an integer to represent the size. Finally I found that adding the following in my resource dictionary allowed me to access primitives:&lt;/p&gt; &lt;div class="reCodeBlock" style="overflow-y: auto;border: #7f9db9 1px solid;"&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;xmlns:system=&lt;/code&gt;&lt;code style="color: blue;"&gt;"clr-namespace:System;assembly=mscorlib"&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin: 0in 0in 10pt;"&gt;I could then do declarations like:&lt;/p&gt; &lt;div class="reCodeBlock" style="overflow-y: auto;border: #7f9db9 1px solid;"&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;&amp;lt;&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;system:Int32&lt;/code&gt; &lt;code style="color: #808080;"&gt;x:Key&lt;/code&gt;&lt;code style="color: #000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"DefaultFontSize"&lt;/code&gt;&lt;code style="color: #000;"&gt;&amp;gt;12&amp;lt;/&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;system:Int32&lt;/code&gt;&lt;code style="color: #000;"&gt;&amp;gt; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;&amp;lt;&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;system:String&lt;/code&gt; &lt;code style="color: #808080;"&gt;x:Key&lt;/code&gt;&lt;code style="color: #000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"DefaultFontFamily"&lt;/code&gt;&lt;code style="color: #000;"&gt;&amp;gt;Arial&amp;lt;/&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;system:String&lt;/code&gt;&lt;code style="color: #000;"&gt;&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;And then create a style using those primitives:&lt;/p&gt; &lt;div class="reCodeBlock" style="overflow-y: auto;border: #7f9db9 1px solid;"&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;&amp;lt;&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Style&lt;/code&gt; &lt;code style="color: #808080;"&gt;x:Key&lt;/code&gt;&lt;code style="color: #000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"CommonText_TextBlock"&lt;/code&gt; &lt;code style="color: #808080;"&gt;TargetType&lt;/code&gt;&lt;code style="color: #000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"TextBlock"&lt;/code&gt;&lt;code style="color: #000;"&gt;&amp;gt; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000;"&gt;&amp;lt;&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Setter&lt;/code&gt; &lt;code style="color: #808080;"&gt;Property&lt;/code&gt;&lt;code style="color: #000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"FontSize"&lt;/code&gt; &lt;code style="color: #808080;"&gt;Value&lt;/code&gt;&lt;code style="color: #000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"{StaticResource DefaultFontSize}"&lt;/code&gt;&lt;code style="color: #000;"&gt;/&amp;gt; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000;"&gt;&amp;lt;&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Setter&lt;/code&gt; &lt;code style="color: #808080;"&gt;Property&lt;/code&gt;&lt;code style="color: #000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"FontFamily"&lt;/code&gt; &lt;code style="color: #808080;"&gt;Value&lt;/code&gt;&lt;code style="color: #000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"{StaticResource DefaultFontFamily}"&lt;/code&gt;&lt;code style="color: #000;"&gt;/&amp;gt; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000;"&gt;&amp;lt;&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Setter&lt;/code&gt; &lt;code style="color: #808080;"&gt;Property&lt;/code&gt;&lt;code style="color: #000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"Foreground"&lt;/code&gt; &lt;code style="color: #808080;"&gt;Value&lt;/code&gt;&lt;code style="color: #000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"{StaticResource DefaultForeground}"&lt;/code&gt; &lt;code style="color: #000;"&gt;/&amp;gt; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;&amp;lt;/&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Style&lt;/code&gt;&lt;code style="color: #000;"&gt;&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=UuVJ9B6NWh4:FysLlNV-Uoc:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=UuVJ9B6NWh4:FysLlNV-Uoc:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=UuVJ9B6NWh4:FysLlNV-Uoc:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?i=UuVJ9B6NWh4:FysLlNV-Uoc:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=UuVJ9B6NWh4:FysLlNV-Uoc:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FalafelBlogs/~4/UuVJ9B6NWh4" height="1" width="1"/&gt;</description>
      <link>http://feeds.falafel.com/~r/FalafelBlogs/~3/UuVJ9B6NWh4/Using_Primitives_with_Silverlight_Styles.aspx</link>
      <author>Scott Frolich</author>
      <comments>http://blog.falafel.com/Blogs/10-08-12/Using_Primitives_with_Silverlight_Styles.aspx</comments>
      <guid isPermaLink="false">2033a247-8d19-4199-9480-4043b9868c6e</guid>
      <pubDate>Thu, 12 Aug 2010 17:23:44 GMT</pubDate>
    <feedburner:origLink>http://blog.falafel.com/Blogs/10-08-12/Using_Primitives_with_Silverlight_Styles.aspx</feedburner:origLink></item>
    <item>
      <title>Synchronously Retrieving Data with WCF RIA Services</title>
      <description>&lt;p style="margin: 0in 0in 10pt;"&gt;&amp;nbsp; I have written quite a few WCF RIA Services applications now and almost every time I need to pre-fetch some data before showing a Silverlight page or dialog. For instance you might need to get all the years and employees available to so you can put them in ComboBoxes for a dialog. You wouldn’t necessarily want to do this in the Loaded event of the dialog because the dialog will come up with empty information then fill in when the query has returned.&lt;/p&gt; &lt;p style="margin: 0in 0in 10pt;"&gt;Another problem is that the code turns ugly and hard to manage if you have multiple queries to run. Let’s say you have 4 queries to run before showing a dialog. You will have this chain of methods in which the completion of the query1 then starts query2 then query2 completes starts query3 then query3 completes then query4 starts then query4 completes and opens the dialog. You can see how this becomes hard to manage.&lt;/p&gt; &lt;p style="margin: 0in 0in 10pt;"&gt;I have come across a few example asynchronous data loaders but I have had trouble with them not working consistently. I’m not sure if it is a problem with the code itself or the fact that it starts a bunch of queries all at once and WCF RIA Services is having trouble so I decided to try a synchronous version. There might be a very slight performance difference with asynchronous queries but I believe them to be minimal in most cases that I have needed to lookup entities and found synchronous to perform just as well in my rudimentary speed tests.&lt;/p&gt; &lt;p style="margin: 0in 0in 10pt;"&gt;The DataLoader I have created is really simple to use.&lt;/p&gt; &lt;p&gt;C#&lt;/p&gt; &lt;div class="reCodeBlock" style="overflow-y: auto;border: #7f9db9 1px solid;"&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;DataLoader bulkDataLoader = &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;new&lt;/code&gt; &lt;code style="color: #000;"&gt;DataLoader(context, DataLoader_Completed); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;bulkDataLoader.AddQuery(&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;new&lt;/code&gt; &lt;code style="color: #000;"&gt;DataLoader.QueryOperation &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { Query = context.GetDepartmentsQuery() }); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;bulkDataLoader.AddQuery(&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;new&lt;/code&gt; &lt;code style="color: #000;"&gt;DataLoader.QueryOperation &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { Query = context.GetEmployeesQuery() }); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;bulkDataLoader.AddQuery(&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;new&lt;/code&gt; &lt;code style="color: #000;"&gt;DataLoader.QueryOperation &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { Query = context.GetEmployeePayHistoriesQuery() }); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;bulkDataLoader.Execute(); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 3px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;private&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;void&lt;/code&gt; &lt;code style="color: #000;"&gt;DataLoader_Completed(DataLoader dataLoader) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;{ &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #008200;"&gt;// do what you need after all the data is loaded &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;} &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;VB&lt;/p&gt; &lt;div class="reCodeBlock" style="overflow-y: auto;border: #7f9db9 1px solid;"&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Dim&lt;/code&gt; &lt;code style="color: #000;"&gt;bulkDataLoader &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;As&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;New&lt;/code&gt; &lt;code style="color: #000;"&gt;DataLoader(context, &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;AddressOf&lt;/code&gt; &lt;code style="color: #000;"&gt;DataLoader_Completed) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;bulkDataLoader.AddQuery(&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;New&lt;/code&gt; &lt;code style="color: #000;"&gt;DataLoader.QueryOperation() &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;With&lt;/code&gt; &lt;code style="color: #000;"&gt;{ _ &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&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;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 51px !important;"&gt;&lt;code style="color: #000;"&gt;.Query = context.GetDepartmentsQuery()}) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;bulkDataLoader.AddQuery(&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;New&lt;/code&gt; &lt;code style="color: #000;"&gt;DataLoader.QueryOperation() &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;With&lt;/code&gt; &lt;code style="color: #000;"&gt;{ _ &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&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;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 51px !important;"&gt;&lt;code style="color: #000;"&gt;.Query = context.GetEmployeesQuery()}) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;bulkDataLoader.AddQuery(&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;New&lt;/code&gt; &lt;code style="color: #000;"&gt;DataLoader.QueryOperation() &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;With&lt;/code&gt; &lt;code style="color: #000;"&gt;{ _ &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&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;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 48px !important;"&gt;&lt;code style="color: #000;"&gt;.Query = context.GetEmployeePayHistoriesQuery()}) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;bulkDataLoader.Execute() &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 3px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Private&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;Sub&lt;/code&gt; &lt;code style="color: #000;"&gt;DataLoader_Completed(&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;ByVal&lt;/code&gt; &lt;code style="color: #000;"&gt;dataLoader &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;As&lt;/code&gt; &lt;code style="color: #000;"&gt;DataLoader) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #008200;"&gt;' do what you need after all the data is loaded &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;End&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;Sub&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin: 0in 0in 10pt;"&gt;You can see from the above examples that three queries are being run and once all three have returned, either successfully or failed, the DataLoader_Completed method will be called where you can either analyze each LoadOperation for its data or just use it in the DomainContext since successfully loaded entities will be in the supplied DomainContext automatically. In addition you can change the load behavior and pass any object you like from the DataLoader definition to the complete action by using the UserState.&lt;/p&gt; &lt;p style="margin: 0in 0in 10pt;"&gt;I’m sure some people will have ideas for enhancements and I’d like to hear about them but I do not start a WCF RIA Services project without having this class in it.&lt;/p&gt; &lt;p style="margin: 0in 0in 10pt;"&gt;The sample solution is attached with three projects (ones for C# and VB) that include the DataLoader in both languages. This sample uses the AdventureWorks2008 database and logs in with integrated security. Edit the Web.config file if necessary to change the connection string to connect to your database. &lt;a href="http://blog.falafel.com/Files/scottfrolich/BulkDataLoader.zip" title="Visual Studio 2010 Three Project Solution Bulk DataLoader Example"&gt;Bulk DataLoader Example&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=KWzKuaXGxSU:4ypJUhE3GPA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=KWzKuaXGxSU:4ypJUhE3GPA:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=KWzKuaXGxSU:4ypJUhE3GPA:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?i=KWzKuaXGxSU:4ypJUhE3GPA:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=KWzKuaXGxSU:4ypJUhE3GPA:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FalafelBlogs/~4/KWzKuaXGxSU" height="1" width="1"/&gt;</description>
      <link>http://feeds.falafel.com/~r/FalafelBlogs/~3/KWzKuaXGxSU/Synchronously_Retrieving_Data_with_WCF_RIA_Services.aspx</link>
      <author>Scott Frolich</author>
      <comments>http://blog.falafel.com/Blogs/10-08-12/Synchronously_Retrieving_Data_with_WCF_RIA_Services.aspx</comments>
      <guid isPermaLink="false">c2d6bc70-2531-4204-a7a4-aec9e3b812c4</guid>
      <pubDate>Thu, 12 Aug 2010 16:52:37 GMT</pubDate>
    <feedburner:origLink>http://blog.falafel.com/Blogs/10-08-12/Synchronously_Retrieving_Data_with_WCF_RIA_Services.aspx</feedburner:origLink></item>
    <item>
      <title>Cloning Objects with .NET</title>
      <description>&lt;p style="margin: 0in 0in 10pt;"&gt;There have been a few instances when I would like to have an identical copy of an object but want them to be different instances. There are a few brute force ways to do this by either copying the values one by one or by using reflection to iterate over variables, properties, etc. The problem is that these methods are not very generic and need to be tweaked for each situation.&lt;/p&gt; &lt;p style="margin: 0in 0in 10pt;"&gt;I have discovered that there are a few ways to clone an object by serializing then de-serializing an object into a new deep-copy instance of that object.&lt;/p&gt; &lt;p style="margin: 0in 0in 10pt;"&gt;&lt;strong&gt;Method 1 – Using BinaryFormatter&lt;/strong&gt;&lt;/p&gt; &lt;p style="margin: 0in 0in 10pt;"&gt;C#&lt;/p&gt; &lt;div class="reCodeBlock" style="overflow-y: auto;border: #7f9db9 1px solid;"&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;private&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;static&lt;/code&gt; &lt;code style="color: #000;"&gt;T BinaryClone&amp;lt;T&amp;gt;(T source) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;{ &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000;"&gt;MemoryStream memStream = &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;new&lt;/code&gt; &lt;code style="color: #000;"&gt;MemoryStream(); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000;"&gt;BinaryFormatter binFormatter = &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;new&lt;/code&gt; &lt;code style="color: #000;"&gt;BinaryFormatter(); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 3px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000;"&gt;binFormatter.Context = &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;new&lt;/code&gt; &lt;code style="color: #000;"&gt;StreamingContext(StreamingContextStates.Clone); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000;"&gt;binFormatter.Serialize(memStream, source); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000;"&gt;memStream.Position = 0; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 3px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;return&lt;/code&gt; &lt;code style="color: #000;"&gt;(T)binFormatter.Deserialize(memStream); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;}&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;VB&lt;/p&gt; &lt;div class="reCodeBlock" style="overflow-y: auto;border: #7f9db9 1px solid;"&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Private&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;Function&lt;/code&gt; &lt;code style="color: #000;"&gt;BinaryClone(Of T)(&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;ByVal&lt;/code&gt; &lt;code style="color: #000;"&gt;source &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;As&lt;/code&gt; &lt;code style="color: #000;"&gt;T) &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;As&lt;/code&gt; &lt;code style="color: #000;"&gt;T &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Dim&lt;/code&gt; &lt;code style="color: #000;"&gt;memStream &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;As&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;New&lt;/code&gt; &lt;code style="color: #000;"&gt;MemoryStream() &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Dim&lt;/code&gt; &lt;code style="color: #000;"&gt;binFormatter &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;As&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;New&lt;/code&gt; &lt;code style="color: #000;"&gt;BinaryFormatter() &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 3px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000;"&gt;binFormatter.Context = &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;New&lt;/code&gt; &lt;code style="color: #000;"&gt;StreamingContext(StreamingContextStates.Clone) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000;"&gt;binFormatter.Serialize(memStream, source) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000;"&gt;memStream.Position = 0 &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 3px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Return&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;DirectCast&lt;/code&gt;&lt;code style="color: #000;"&gt;(binFormatter.Deserialize(memStream), T) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;End&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;Function&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;The BinaryClone method will take any object marked with the SerializableAttribute and return a new instance of that object.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin: 0in 0in 10pt;"&gt;&lt;strong&gt;Method 2 – Using DataContractSerializer&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;C#&lt;/p&gt; &lt;div class="reCodeBlock" style="overflow-y: auto;border: #7f9db9 1px solid;"&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;public&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;static&lt;/code&gt; &lt;code style="color: #000;"&gt;T DataContractClone&amp;lt;T&amp;gt;(T source) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;{ &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000;"&gt;DataContractSerializer serializer; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000;"&gt;serializer = &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;new&lt;/code&gt; &lt;code style="color: #000;"&gt;DataContractSerializer(&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;typeof&lt;/code&gt;&lt;code style="color: #000;"&gt;(T)); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 3px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;using&lt;/code&gt; &lt;code style="color: #000;"&gt;(MemoryStream ms = &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;new&lt;/code&gt; &lt;code style="color: #000;"&gt;MemoryStream()) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000;"&gt;{ &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000;"&gt;serializer.WriteObject(ms, source); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000;"&gt;ms.Seek(0, SeekOrigin.Begin); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 3px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;return&lt;/code&gt; &lt;code style="color: #000;"&gt;(T)serializer.ReadObject(ms); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000;"&gt;} &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;} &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;VB&lt;/p&gt; &lt;div class="reCodeBlock" style="overflow-y: auto;border: #7f9db9 1px solid;"&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Public&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;Function&lt;/code&gt; &lt;code style="color: #000;"&gt;DataContractClone(Of T)(&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;ByVal&lt;/code&gt; &lt;code style="color: #000;"&gt;source &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;As&lt;/code&gt; &lt;code style="color: #000;"&gt;T) &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;As&lt;/code&gt; &lt;code style="color: #000;"&gt;T &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Dim&lt;/code&gt; &lt;code style="color: #000;"&gt;serializer &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;As&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;New&lt;/code&gt; &lt;code style="color: #000;"&gt;DataContractSerializer(&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;GetType&lt;/code&gt;&lt;code style="color: #000;"&gt;(T)) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 3px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000;"&gt;Using ms &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;As&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;New&lt;/code&gt; &lt;code style="color: #000;"&gt;MemoryStream &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000;"&gt;serializer.WriteObject(ms, source) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000;"&gt;ms.Seek(0, SeekOrigin.Begin) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 3px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Return&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;DirectCast&lt;/code&gt;&lt;code style="color: #000;"&gt;(serializer.ReadObject(ms), T) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;End&lt;/code&gt; &lt;code style="color: #000;"&gt;Using &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;End&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;Function&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin: 0in 0in 10pt;"&gt;The DataContractClone method will also take and return a new instance of an object as long as the class has the DataContractAttribute and each public variable has the DataMemberAttribute. One advantage the DataContractClone method has over BinaryClone is that DataContractClone can also be used in Silverlight where the BinaryFormatter is unavailable.&lt;/p&gt; &lt;p style="margin: 0in 0in 10pt;"&gt;The above methods can also be converted to extension methods for easy use throughout your projects. For example.&lt;/p&gt; &lt;p style="margin: 0in 0in 10pt;"&gt;C#&lt;/p&gt; &lt;div class="reCodeBlock" style="overflow-y: auto;border: #7f9db9 1px solid;"&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;public&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;static&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;class&lt;/code&gt; &lt;code style="color: #000;"&gt;ExtensionMethods &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;{ &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;public&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;static&lt;/code&gt; &lt;code style="color: #000;"&gt;T DataContractClone&amp;lt;T&amp;gt;(&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;this&lt;/code&gt; &lt;code style="color: #000;"&gt;T source) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000;"&gt;{ &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000;"&gt;DataContractSerializer serializer; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000;"&gt;serializer = &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;new&lt;/code&gt; &lt;code style="color: #000;"&gt;DataContractSerializer(&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;typeof&lt;/code&gt;&lt;code style="color: #000;"&gt;(T)); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 3px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;using&lt;/code&gt; &lt;code style="color: #000;"&gt;(MemoryStream ms = &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;new&lt;/code&gt; &lt;code style="color: #000;"&gt;MemoryStream()) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000;"&gt;{ &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&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;&lt;/code&gt;&lt;span style="margin-left: 36px !important;"&gt;&lt;code style="color: #000;"&gt;serializer.WriteObject(ms, source); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&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;&lt;/code&gt;&lt;span style="margin-left: 36px !important;"&gt;&lt;code style="color: #000;"&gt;ms.Seek(0, SeekOrigin.Begin); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 3px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&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;&lt;/code&gt;&lt;span style="margin-left: 36px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;return&lt;/code&gt; &lt;code style="color: #000;"&gt;(T)serializer.ReadObject(ms); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000;"&gt;} &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000;"&gt;} &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;} &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;VB&lt;/p&gt; &lt;div class="reCodeBlock" style="overflow-y: auto;border: #7f9db9 1px solid;"&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Module&lt;/code&gt; &lt;code style="color: #000;"&gt;ExtensionMethods &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000;"&gt;&amp;lt;System.Runtime.CompilerServices.Extension()&amp;gt; _ &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Public&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;Function&lt;/code&gt; &lt;code style="color: #000;"&gt;DataContractClone(Of T)(&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;ByVal&lt;/code&gt; &lt;code style="color: #000;"&gt;source &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;As&lt;/code&gt; &lt;code style="color: #000;"&gt;T) &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;As&lt;/code&gt; &lt;code style="color: #000;"&gt;T &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Dim&lt;/code&gt; &lt;code style="color: #000;"&gt;serializer &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;As&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;New&lt;/code&gt; &lt;code style="color: #000;"&gt;DataContractSerializer(&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;GetType&lt;/code&gt;&lt;code style="color: #000;"&gt;(T)) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 3px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000;"&gt;Using ms &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;As&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;New&lt;/code&gt; &lt;code style="color: #000;"&gt;MemoryStream &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&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;&lt;/code&gt;&lt;span style="margin-left: 36px !important;"&gt;&lt;code style="color: #000;"&gt;serializer.WriteObject(ms, source) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&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;&lt;/code&gt;&lt;span style="margin-left: 36px !important;"&gt;&lt;code style="color: #000;"&gt;ms.Seek(0, SeekOrigin.Begin) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 3px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&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;&lt;/code&gt;&lt;span style="margin-left: 36px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Return&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;DirectCast&lt;/code&gt;&lt;code style="color: #000;"&gt;(serializer.ReadObject(ms), T) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;End&lt;/code&gt; &lt;code style="color: #000;"&gt;Using &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;End&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;Function&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;End&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;Module&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin: 0in 0in 10pt;"&gt;Here’s an example of two classes that are ready for cloning with either of the above methods. If this is used in Silverlight remove the SerializableAttribute since it is unavailable.&lt;/p&gt; &lt;p&gt;C#&lt;/p&gt; &lt;div class="reCodeBlock" style="overflow-y: auto;border: #7f9db9 1px solid;"&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;[Serializable] &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;[DataContract] &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;class&lt;/code&gt; &lt;code style="color: #000;"&gt;Class1 &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;{ &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000;"&gt;[DataMember] &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;public&lt;/code&gt; &lt;code style="color: #000;"&gt;String Value = &lt;/code&gt;&lt;code style="color: blue;"&gt;"Hello"&lt;/code&gt;&lt;code style="color: #000;"&gt;; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000;"&gt;[DataMember] &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;public&lt;/code&gt; &lt;code style="color: #000;"&gt;Class2 AnotherClass = &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;new&lt;/code&gt; &lt;code style="color: #000;"&gt;Class2(); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;} &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 3px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;[Serializable] &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;[DataContract] &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;class&lt;/code&gt; &lt;code style="color: #000;"&gt;Class2 &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;{ &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000;"&gt;[DataMember] &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;public&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;int&lt;/code&gt; &lt;code style="color: #000;"&gt;AnotherValue = 123; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;} &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;VB&lt;/p&gt; &lt;div class="reCodeBlock" style="overflow-y: auto;border: #7f9db9 1px solid;"&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;&amp;lt;Serializable()&amp;gt; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;&amp;lt;DataContract()&amp;gt; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Class&lt;/code&gt; &lt;code style="color: #000;"&gt;Class1 &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000;"&gt;&amp;lt;DataMember()&amp;gt; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Public&lt;/code&gt; &lt;code style="color: #000;"&gt;Value &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;As&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;String&lt;/code&gt; &lt;code style="color: #000;"&gt;= &lt;/code&gt;&lt;code style="color: blue;"&gt;"Hello"&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000;"&gt;&amp;lt;DataMember()&amp;gt; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Public&lt;/code&gt; &lt;code style="color: #000;"&gt;AnotherClass &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;As&lt;/code&gt; &lt;code style="color: #000;"&gt;Class2 = &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;New&lt;/code&gt; &lt;code style="color: #000;"&gt;Class2() &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;End&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;Class&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 3px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;&amp;lt;Serializable()&amp;gt; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;&amp;lt;DataContract()&amp;gt; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Class&lt;/code&gt; &lt;code style="color: #000;"&gt;Class2 &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000;"&gt;&amp;lt;DataMember()&amp;gt; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Public&lt;/code&gt; &lt;code style="color: #000;"&gt;AnotherValue &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;As&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;Integer&lt;/code&gt; &lt;code style="color: #000;"&gt;= 123 &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;End&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;Class&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin: 0in 0in 10pt;"&gt;Then the code to test the cloning of both methods (Again you cannot use BinaryClone/BinaryFormatter with Silverlight):&lt;/p&gt; &lt;p&gt;C#&lt;/p&gt; &lt;div class="reCodeBlock" style="overflow-y: auto;border: #7f9db9 1px solid;"&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;Class1 c1 = &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;new&lt;/code&gt; &lt;code style="color: #000;"&gt;Class1(); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 3px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;Class1 c1a = c1; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;System.Console.WriteLine(&lt;/code&gt;&lt;code style="color: blue;"&gt;"Before DataContractClone same object? "&lt;/code&gt; &lt;code style="color: #000;"&gt;+&amp;nbsp; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 75px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;object&lt;/code&gt;&lt;code style="color: #000;"&gt;.ReferenceEquals(c1, c1a)); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;c1a = DataContractClone(c1); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;System.Console.WriteLine(&lt;/code&gt;&lt;code style="color: blue;"&gt;"After DataContractClone same object? "&lt;/code&gt; &lt;code style="color: #000;"&gt;+&amp;nbsp; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 75px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;object&lt;/code&gt;&lt;code style="color: #000;"&gt;.ReferenceEquals(c1, c1a)); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 3px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;Class1 c1b = c1; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;System.Console.WriteLine(&lt;/code&gt;&lt;code style="color: blue;"&gt;"Before BinaryClone same object? "&lt;/code&gt; &lt;code style="color: #000;"&gt;+ &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 75px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;object&lt;/code&gt;&lt;code style="color: #000;"&gt;.ReferenceEquals(c1, c1b)); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;c1b = BinaryClone(c1); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;System.Console.WriteLine(&lt;/code&gt;&lt;code style="color: blue;"&gt;"After BinaryClone same object? "&lt;/code&gt; &lt;code style="color: #000;"&gt;+ &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 75px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;object&lt;/code&gt;&lt;code style="color: #000;"&gt;.ReferenceEquals(c1, c1b)); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 3px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #008200;"&gt;// using extension methods defined in ExtensionMethods.cs &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;Class1 bc = c1.BinaryClone(); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;Class1 dcc = c1.DataContractClone(); &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;VB&lt;/p&gt; &lt;div class="reCodeBlock" style="overflow-y: auto;border: #7f9db9 1px solid;"&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Dim&lt;/code&gt; &lt;code style="color: #000;"&gt;c1 &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;As&lt;/code&gt; &lt;code style="color: #000;"&gt;Class1 = &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;New&lt;/code&gt; &lt;code style="color: #000;"&gt;Class1() &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 3px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Dim&lt;/code&gt; &lt;code style="color: #000;"&gt;c1a &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;As&lt;/code&gt; &lt;code style="color: #000;"&gt;Class1 = c1 &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;System.Console.WriteLine(&lt;/code&gt;&lt;code style="color: blue;"&gt;"Before DataContractClone same object? "&lt;/code&gt; &lt;code style="color: #000;"&gt;&amp;amp; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 75px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Object&lt;/code&gt;&lt;code style="color: #000;"&gt;.ReferenceEquals(c1, c1a)) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;c1a = DataContractClone(c1) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;System.Console.WriteLine(&lt;/code&gt;&lt;code style="color: blue;"&gt;"After DataContractClone same object? "&lt;/code&gt; &lt;code style="color: #000;"&gt;&amp;amp; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 75px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Object&lt;/code&gt;&lt;code style="color: #000;"&gt;.ReferenceEquals(c1, c1a)) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 3px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Dim&lt;/code&gt; &lt;code style="color: #000;"&gt;c1b &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;As&lt;/code&gt; &lt;code style="color: #000;"&gt;Class1 = c1 &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;System.Console.WriteLine(&lt;/code&gt;&lt;code style="color: blue;"&gt;"Before BinaryClone same object? "&lt;/code&gt; &lt;code style="color: #000;"&gt;&amp;amp; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 75px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Object&lt;/code&gt;&lt;code style="color: #000;"&gt;.ReferenceEquals(c1, c1b)) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;c1b = BinaryClone(c1) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;System.Console.WriteLine(&lt;/code&gt;&lt;code style="color: blue;"&gt;"After BinaryClone same object? "&lt;/code&gt; &lt;code style="color: #000;"&gt;&amp;amp; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 75px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Object&lt;/code&gt;&lt;code style="color: #000;"&gt;.ReferenceEquals(c1, c1b)) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 3px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #008200;"&gt;' using extension methods defined in ExtensionMethods.vb &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Dim&lt;/code&gt; &lt;code style="color: #000;"&gt;bc &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;As&lt;/code&gt; &lt;code style="color: #000;"&gt;Class1 = c1.BinaryClone() &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;Dim&lt;/code&gt; &lt;code style="color: #000;"&gt;dcc &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;As&lt;/code&gt; &lt;code style="color: #000;"&gt;Class1 = c1.DataContractClone() &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="margin: 0in 0in 10pt;"&gt;When you have a choice of serialization methods for cloning I believe it comes down to which one is easier to use for your case. There are several discussions around how BinaryFormatter creates a smaller representation verses DataContractSerializer XML representation but when this data is not sent over the wire these differences make little difference. &amp;nbsp;When using Silverlight, you need to use the DataContractSerializer and when using WCF RIA Services the entities already have the attributes on the classes and variables and are ready to clone.&lt;/p&gt; &lt;p&gt;For your convenience attached to this post is a four project solution created in Visual Studio 2010 that includes two Silverlight projects (C#/VB) and two console projects (C#/VB). The console projects also include use of sample extension methods. &lt;a href="http://blog.falafel.com/Files/scottfrolich/CloningExample.zip" title="Cloning Four Project Visual Studio 2010 Solution"&gt;Cloning Example&lt;/a&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=TKVa1y77SUQ:J7vKnkmFFn4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=TKVa1y77SUQ:J7vKnkmFFn4:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=TKVa1y77SUQ:J7vKnkmFFn4:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?i=TKVa1y77SUQ:J7vKnkmFFn4:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=TKVa1y77SUQ:J7vKnkmFFn4:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FalafelBlogs/~4/TKVa1y77SUQ" height="1" width="1"/&gt;</description>
      <link>http://feeds.falafel.com/~r/FalafelBlogs/~3/TKVa1y77SUQ/Cloning_Objects_with_NET.aspx</link>
      <author>Scott Frolich</author>
      <comments>http://blog.falafel.com/Blogs/10-08-11/Cloning_Objects_with_NET.aspx</comments>
      <guid isPermaLink="false">8b47fbfe-d4c9-425f-b612-d7ff5f4a2015</guid>
      <pubDate>Wed, 11 Aug 2010 16:25:19 GMT</pubDate>
    <feedburner:origLink>http://blog.falafel.com/Blogs/10-08-11/Cloning_Objects_with_NET.aspx</feedburner:origLink></item>
    <item>
      <title>ASP.NET MasterPage metatag localization</title>
      <description>&lt;p&gt;I've been working on a multilanguage web site using ASP.NET localization. I wanted to return unique meta tags for each page in the user's language. There are a handful of ways to accomplish this (MasterPage codebehind, base page codebehind, etc); here's the approach I took:&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;ol&gt; &lt;li&gt;My web site was already taking advantage of Web.Sitemap, so I decided it would be best to store the meta tags there as a custom attribute. Web.Sitemap's resources can be globalized, so I actually don't need to do anything special to the sitemap besides set enableLocalization="true" and assign a unique resourceKey attribute if one does not already exist on each siteMapNode, e.g.&lt;br /&gt; &lt;br /&gt; &lt;div class="reCodeBlock" style="border: 1px  solid  #7f9db9;overflow-y: auto;"&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000000;"&gt;&amp;lt;?&lt;/code&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;xml&lt;/code&gt; &lt;code style="color: #808080;"&gt;version&lt;/code&gt;&lt;code style="color: #000000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"1.0"&lt;/code&gt; &lt;code style="color: #808080;"&gt;encoding&lt;/code&gt;&lt;code style="color: #000000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"utf-8"&lt;/code&gt; &lt;code style="color: #000000;"&gt;?&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000000;"&gt;&amp;lt;&lt;/code&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;siteMap&lt;/code&gt; &lt;code style="color: #808080;"&gt;xmlns&lt;/code&gt;&lt;code style="color: #000000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"&lt;a href="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0"&gt;http://schemas.microsoft.com/AspNet/SiteMap-File-1.0&lt;/a&gt;"&lt;/code&gt; &lt;code style="color: #808080;"&gt;enableLocalization&lt;/code&gt;&lt;code style="color: #000000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"true"&lt;/code&gt; &lt;code style="color: #000000;"&gt;&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000000;"&gt;&amp;lt;&lt;/code&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;siteMapNode&lt;/code&gt; &lt;code style="color: #808080;"&gt;url&lt;/code&gt;&lt;code style="color: #000000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"~/Default.aspx"&lt;/code&gt; &lt;code style="color: #808080;"&gt;resourceKey&lt;/code&gt;&lt;code style="color: #000000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"Home"&lt;/code&gt; &lt;code style="color: #000000;"&gt;/&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000000;"&gt;&amp;lt;/&lt;/code&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;siteMap&lt;/code&gt;&lt;code style="color: #000000;"&gt;&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;&lt;br /&gt; &lt;/p&gt; &lt;/li&gt; &lt;li&gt;Now I am ready to add the meta tags themselves. These will be placed in the Web.sitemap.resx file(s) under App_GlobalResources. I'll add two rows for each resourceKey. For the example above, I'll create a row named &lt;strong&gt;&lt;em&gt;Home.metaKeywords&lt;/em&gt;&lt;/strong&gt; to store the keywords and a row named &lt;strong&gt;&lt;em&gt;Home.metaDescription&lt;/em&gt;&lt;/strong&gt; to store the page description. I'll need to create those rows in every Web.sitemap.*.resx file to store the language-specific tags and descriptions.&lt;br /&gt; &lt;br /&gt; &lt;/li&gt; &lt;li&gt;Once that's done, we're ready to start the work of inserting those tags into the page. In the MasterPage, I create two ContentPlaceHolder controls in the head section.&amp;nbsp;These ContentPlaceHolders will be used to insert the appropriate meta tags when the page is rendered.&lt;br /&gt; &lt;br /&gt; &lt;p&gt; &lt;/p&gt; &lt;div class="reCodeBlock" style="border: 1px  solid  #7f9db9;overflow-y: auto;"&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000000;"&gt;&amp;lt;&lt;/code&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;head&lt;/code&gt; &lt;code style="color: #808080;"&gt;id&lt;/code&gt;&lt;code style="color: #000000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"Head1"&lt;/code&gt; &lt;code style="color: #808080;"&gt;runat&lt;/code&gt;&lt;code style="color: #000000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"server"&lt;/code&gt;&lt;code style="color: #000000;"&gt;&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000000;"&gt;&amp;lt;&lt;/code&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;asp:ContentPlaceHolder&lt;/code&gt; &lt;code style="color: #808080;"&gt;ID&lt;/code&gt;&lt;code style="color: #000000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"METAKeywords"&lt;/code&gt; &lt;code style="color: #808080;"&gt;runat&lt;/code&gt;&lt;code style="color: #000000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"server"&lt;/code&gt; &lt;code style="color: #000000;"&gt;/&amp;gt; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000000;"&gt;&amp;lt;&lt;/code&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;asp:ContentPlaceHolder&lt;/code&gt; &lt;code style="color: #808080;"&gt;ID&lt;/code&gt;&lt;code style="color: #000000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"METADescription"&lt;/code&gt; &lt;code style="color: #808080;"&gt;runat&lt;/code&gt;&lt;code style="color: #000000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"server"&lt;/code&gt; &lt;code style="color: #000000;"&gt;/&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000000;"&gt;&amp;lt;/&lt;/code&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;head&lt;/code&gt;&lt;code style="color: #000000;"&gt;&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;/li&gt; &lt;li&gt;Normally we would populate those ContentPlaceHolders in the individual pages, but that sounds like a lot of work. I suggest we let the MasterPage's codebehind take care of it.&lt;br /&gt; &lt;br /&gt; &lt;div class="reCodeBlock" style="border: 1px  solid  #7f9db9;overflow-y: auto;"&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000000;"&gt;public partial class MyMasterPage : System.Web.UI.MasterPage&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000000;"&gt;{&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000000;"&gt;protected void Page_Load(object sender, EventArgs e)&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000000;"&gt;{&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000000;"&gt;ParseMetaTags();&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000000;"&gt;}&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000000;"&gt;private void ParseMetaTags()&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000000;"&gt;{&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000000;"&gt;HtmlMeta description = new HtmlMeta();&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000000;"&gt;HtmlMeta keywords = new HtmlMeta();&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000000;"&gt;description.Name = "description";&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000000;"&gt;description.Content = SiteMap.CurrentNode["metaDesc"];&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000000;"&gt;keywords.Name = "keywords";&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000000;"&gt;keywords.Content = SiteMap.CurrentNode["metaKeywords"];&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000000;"&gt;METADescription.Controls.Add(description);&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000000;"&gt;METAKeywords.Controls.Add(keywords);&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000000;"&gt;}&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000000;"&gt;}&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;br /&gt;
    As you can see, I've accessed the language-specific tags from the SiteMap control using our custom attributes metaDesc and metaKeywords (which automatically retrieved them from the appropriate resource file), created HtmlMeta controls and added them to the ContentPlaceHolders (METADescription and METAKeywords) before rendering the page.&lt;/li&gt; &lt;/ol&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=XulmOMR4nvc:8jZmGNbv6rg:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=XulmOMR4nvc:8jZmGNbv6rg:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=XulmOMR4nvc:8jZmGNbv6rg:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?i=XulmOMR4nvc:8jZmGNbv6rg:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=XulmOMR4nvc:8jZmGNbv6rg:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FalafelBlogs/~4/XulmOMR4nvc" height="1" width="1"/&gt;</description>
      <link>http://feeds.falafel.com/~r/FalafelBlogs/~3/XulmOMR4nvc/ASP_NET_MasterPage_metatag_localization.aspx</link>
      <author>Brad Divine</author>
      <comments>http://blog.falafel.com/Blogs/10-08-10/ASP_NET_MasterPage_metatag_localization.aspx</comments>
      <guid isPermaLink="false">00291c37-26b8-4210-9e2c-60a9482742b5</guid>
      <pubDate>Tue, 10 Aug 2010 19:14:34 GMT</pubDate>
    <feedburner:origLink>http://blog.falafel.com/Blogs/10-08-10/ASP_NET_MasterPage_metatag_localization.aspx</feedburner:origLink></item>
    <item>
      <title>Falafel Mobile is HERE!</title>
      <description>&lt;p&gt;&lt;strong&gt;Falafel mobile experts make developing for your mobile market easier and more efficient.&lt;/strong&gt;&lt;/p&gt; &lt;p&gt; The Falafel Mobile Team is pleased to announce the launch of Falafel Mobile, the best mobile application development assistance offered.&lt;/p&gt; &lt;p&gt;Executives need access to key data points anytime, anywhere. Gone is the nine to five work day, your managers and users need to be able to view data, receive notifications, and take appropriate action, no matter where they are, and at what time of day, using the mobile device of their choice. Your Line of Business applications no longer have to be constrained to the confines of your office and VPN, now you can securely access your systems through mobile extensions from any location that has connectivity. Today’s powerful devices allow you to do much more than just email on the go. &lt;/p&gt; &lt;p&gt;&amp;nbsp;
&lt;/p&gt; &lt;table&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;&lt;img src="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-FalafelMobileisHERE_F6A4-clip_image002_thumb.sflb.ashx" style="border: 0px;  display: inline; margin-left: 0px; margin-right: 0px; float: left;" title="clip_image002" alt="clip_image002" width="240" height="187" /&gt;&amp;nbsp;&lt;/td&gt; &lt;td valign="top"&gt;&amp;nbsp;Falafel Software has a proven track record of delivering world-class Windows and Web applications. Be it iPhone, iPad, Android or the upcoming Windows Phone,&lt;strong&gt;&amp;nbsp;we are ready&amp;nbsp;&lt;/strong&gt;to mobilize your business with our exquisite Consulting, World-class Training, well-executed Software and unique Solutions.&lt;br /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;p&gt;&lt;br /&gt; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;Benefits of Falafel’s Mobile Application Development:&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Faster time to market &lt;/li&gt; &lt;li&gt;Top quality results &lt;/li&gt; &lt;li&gt;Proven experts at the ready &lt;/li&gt; &lt;li&gt;Your customer’s mobile expectations are met &lt;/li&gt; &lt;li&gt;User Interface and User Experience design tailored to the various hand held formats and challenges &lt;/li&gt; &lt;li&gt;One stop shop for all the layers of your application, from mobile interface to communications, middle tier and back end &lt;/li&gt; &lt;li&gt;Business grade development, enterprise ready performance &lt;/li&gt; &lt;/ul&gt; &lt;p&gt;&lt;strong&gt;Falafel 2 Go &lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Falafel created a mobile solution which allows our customers to view our upcoming training schedule, quickly view our Twitter Tweets, or read our excellent technical blogs – all very easily from their mobile devices. Falafel 2 Go is available in both the iTunes App Store and the Android Marketplace.&lt;/p&gt; &lt;p&gt;&lt;a href="http://itunes.com/apps/falafelsoftwareinc"&gt;http://itunes.com/apps/falafelsoftwareinc&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Session Viewer &lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Falafel is also developing an exciting mobile app for Silicon Valley Code Camp 2010 which will enable attendees to view and manage info about sessions, tracks, rooms, and speakers – enriching their conference experience.&lt;/p&gt; &lt;p&gt;Code Camp is a 2 day, free, developer conference covering many development technologies, with currently over 100 technical sessions and 700+ attendees. &lt;/p&gt; &lt;p&gt;&lt;a href="http://www.siliconvalley-codecamp.com"&gt;http://www.siliconvalley-codecamp.com&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Session Viewer will also be used at DevReach in Bulgaria. It will be available on the iPad, iPhone, WinPhone and Android devices.&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.devreach.com/"&gt;http://www.devreach.com/&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=5NUY_gn0kXc:LJcdaPo4cs4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=5NUY_gn0kXc:LJcdaPo4cs4:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=5NUY_gn0kXc:LJcdaPo4cs4:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?i=5NUY_gn0kXc:LJcdaPo4cs4:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=5NUY_gn0kXc:LJcdaPo4cs4:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FalafelBlogs/~4/5NUY_gn0kXc" height="1" width="1"/&gt;</description>
      <link>http://feeds.falafel.com/~r/FalafelBlogs/~3/5NUY_gn0kXc/Falafel_Mobile_is_HERE.aspx</link>
      <author>Lino Tadros</author>
      <comments>http://blog.falafel.com/Blogs/10-08-10/Falafel_Mobile_is_HERE.aspx</comments>
      <guid isPermaLink="false">052e6f69-dff6-481f-93c4-e7150fa8fa7c</guid>
      <pubDate>Tue, 10 Aug 2010 13:00:00 GMT</pubDate>
    <feedburner:origLink>http://blog.falafel.com/Blogs/10-08-10/Falafel_Mobile_is_HERE.aspx</feedburner:origLink></item>
    <item>
      <title>Sitefinity 4 Generic APIs vs Fluent APIs</title>
      <description>&lt;p&gt;I just released a &lt;a href="http://tv.falafel.com/default/10-08-08/Sitefinity_4_0_APIs_vs_Fluent_APIs.aspx"&gt;new video&lt;/a&gt; demonstrating the power of the new APIs in Sitefinity 4.0 Beta that was just released last week by the Telerik team (CONGRATULATIONS! to the entire Telerik team worldwide).&lt;/p&gt; &lt;p&gt;The essence of the video was to demonstrate the use of the regular APIs to create a new PAGE into the system using two different approaches:&lt;/p&gt; &lt;p&gt;1- The Regular API way that most core developers will use that require understanding of the architecture and the fundamental knowledge of how the Object hierarchy relates to the database layer behind Sitefinity 4.0&lt;/p&gt; &lt;p&gt;2- The FLUENT API way that does not require the knowledge from the previous point and was made for designer and developers to be able to accomplish jobs into the Sitefinity system really quickly working on Objects in an atomic way to accomplish a task.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Both ways have their uses and make Sitefinity 4 extremely powerful in bringing the level of integration into the system very easy and powerful.&lt;/p&gt; &lt;p&gt;I see the resemblance to the old days when we used VBA to write macros against Word, Excel, Powerpoint, etc… A lot of people did not really care about learning about COM, Type Libraries, IUnknown, IDispatch, etc… they just want to Create an Excel document, write some cells to it and save it.&amp;nbsp; VBA allowed for that very easily by hiding the complexity of the system behind the scene.&amp;nbsp; For some others that was not enough, they wanted to attach to a specific instance of Excel, embed their own ActiveX Control into the spreadsheet and communicate both ways with their internal system, for those the COM layer was available and ready to program against as long as you understood the relationships between the Application, Workbook, Worksheet, Range, Cell, etc…&lt;/p&gt; &lt;p&gt;Same thing here in Sitefinity 4, and I believe it is a very welcome addition to that excellent platform that will bridge the gap between IT professionals and Developers to get tasks accomplished quickly in Sitefinity.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;First, the code I used for the Generic API to create a new Page is here below based on a Button click event on a test page I created:&lt;/p&gt; &lt;p&gt;&amp;nbsp;
&lt;div class="reCodeBlock" style="border: 1px  solid  #7f9db9;overflow-y: auto;"&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;protected&lt;/code&gt; &lt;code style="color: #006699; font-weight: bold;"&gt;void&lt;/code&gt; &lt;code style="color: #000000;"&gt;Button1_Click(&lt;/code&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;object&lt;/code&gt; &lt;code style="color: #000000;"&gt;sender, EventArgs e)&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000000;"&gt;{&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: #000000;"&gt;PageManager manager = PageManager.GetManager();&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: #000000;"&gt;PageData pagedata = manager.CreatePageData();&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: #000000;"&gt;pagedata.Template = manager.GetTemplates().First();&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: #000000;"&gt;pagedata.HtmlTitle = &lt;/code&gt;&lt;code style="color: blue;"&gt;"Lino testing page"&lt;/code&gt;&lt;code style="color: #000000;"&gt;;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: #000000;"&gt;PageNode node = manager.CreatePageNode();&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: #000000;"&gt;node.Title = &lt;/code&gt;&lt;code style="color: blue;"&gt;"Lino Test Page"&lt;/code&gt;&lt;code style="color: #000000;"&gt;;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: #000000;"&gt;node.ShowInNavigation = &lt;/code&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;true&lt;/code&gt;&lt;code style="color: #000000;"&gt;;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: #000000;"&gt;node.UrlName = &lt;/code&gt;&lt;code style="color: blue;"&gt;"LinoPage1"&lt;/code&gt;&lt;code style="color: #000000;"&gt;;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: #000000;"&gt;var parent = manager.GetPageNode(SiteInitializer.FrontendRootNodeId);&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: #000000;"&gt;manager.ChangeParent(node, parent);&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: #000000;"&gt;node.Page = pagedata;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: #000000;"&gt;manager.SaveChanges();&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: #000000;"&gt;SiteMapBase.Cache.Flush(); &lt;/code&gt;&lt;code style="color: #008200;"&gt;// This is needed only for the Beta&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000000;"&gt;}&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/p&gt; &lt;p&gt;The main points as you will see in the video is to learn the relationship between PageManager, PageData and PageNode objects and how the system brings them all together to communicate with the OpenAccess ORM layer to place the new created page in its correct place in the database with all its corresponding data.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Finally, the code for the alternative method using FLUENT APIs is found below to accomplish the same thing:&lt;/p&gt; &lt;p&gt;&amp;nbsp;
&lt;div class="reCodeBlock" style="border: 1px  solid  #7f9db9;overflow-y: auto;"&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;protected&lt;/code&gt; &lt;code style="color: #006699; font-weight: bold;"&gt;void&lt;/code&gt; &lt;code style="color: #000000;"&gt;Button2_Click(&lt;/code&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;object&lt;/code&gt; &lt;code style="color: #000000;"&gt;sender, EventArgs e)&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000000;"&gt;{&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: #000000;"&gt;PageManager pmanager = &lt;/code&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;new&lt;/code&gt; &lt;code style="color: #000000;"&gt;PageManager();&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: #000000;"&gt;Guid tempGuid = pmanager.GetTemplates().First().Id;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: #000000;"&gt;App.WorkWith()&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 15px !important;"&gt;&lt;code style="color: #000000;"&gt;.Page()&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 15px !important;"&gt;&lt;code style="color: #000000;"&gt;.CreateNewStandardPage(PageLocation.Frontend)&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 15px !important;"&gt;&lt;code style="color: #000000;"&gt;.Do(p =&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000000;"&gt;{&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 33px !important;"&gt;&lt;code style="color: #000000;"&gt;p.Name = &lt;/code&gt;&lt;code style="color: blue;"&gt;"Lino Page 2"&lt;/code&gt;&lt;code style="color: #000000;"&gt;;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 33px !important;"&gt;&lt;code style="color: #000000;"&gt;p.Title = &lt;/code&gt;&lt;code style="color: blue;"&gt;"Lino Second Page"&lt;/code&gt;&lt;code style="color: #000000;"&gt;;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 33px !important;"&gt;&lt;code style="color: #000000;"&gt;p.ShowInNavigation = &lt;/code&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;true&lt;/code&gt;&lt;code style="color: #000000;"&gt;;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 33px !important;"&gt;&lt;code style="color: #000000;"&gt;p.UrlName = &lt;/code&gt;&lt;code style="color: blue;"&gt;"Lino2Page"&lt;/code&gt;&lt;code style="color: #000000;"&gt;;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 27px !important;"&gt;&lt;code style="color: #000000;"&gt;})&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 15px !important;"&gt;&lt;code style="color: #000000;"&gt;.SetTemplateTo(tempGuid)&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 15px !important;"&gt;&lt;code style="color: #000000;"&gt;.SaveChanges();&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 15px !important;"&gt;&lt;code style="color: #000000;"&gt;SiteMapBase.Cache.Flush();&amp;nbsp; &lt;/code&gt;&lt;code style="color: #008200;"&gt;// This is needed only for the Beta&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000000;"&gt;}&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/p&gt; &lt;p&gt;Notice that the entire instruction occurred in one line using the “App” object that allows you to choose a preferred Object to “workwith” and then focus on that Object to accomplish whatever task specific to that object without worrying about what the OpenAccess ORM layer needs or the other objects in the hierarchy require to make it work.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Hope this gives you an entry into the power of using the Sitefinity 4.0 APIs and Fluent APIs and I would be interested in your opinion and recommendation for other videos and blogs to make Sitefinity 4.0 Development easier for everyone.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=P2JBKqP6I80:umZ4k3y0Nts:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=P2JBKqP6I80:umZ4k3y0Nts:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=P2JBKqP6I80:umZ4k3y0Nts:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?i=P2JBKqP6I80:umZ4k3y0Nts:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=P2JBKqP6I80:umZ4k3y0Nts:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FalafelBlogs/~4/P2JBKqP6I80" height="1" width="1"/&gt;</description>
      <link>http://feeds.falafel.com/~r/FalafelBlogs/~3/P2JBKqP6I80/Sitefinity_4_Generic_APIs_vs_Fluent_APIs.aspx</link>
      <author>Lino Tadros</author>
      <comments>http://blog.falafel.com/Blogs/10-08-09/Sitefinity_4_Generic_APIs_vs_Fluent_APIs.aspx</comments>
      <guid isPermaLink="false">dd2d4c80-b72b-42b0-ada8-7c921255351c</guid>
      <pubDate>Mon, 09 Aug 2010 16:00:00 GMT</pubDate>
    <feedburner:origLink>http://blog.falafel.com/Blogs/10-08-09/Sitefinity_4_Generic_APIs_vs_Fluent_APIs.aspx</feedburner:origLink></item>
    <item>
      <title>It's a little early for Easter but.....</title>
      <description>It's not unknown that we like to have fun at Falafel Software. So we've decided to add a new feature to the site.&lt;br /&gt; &lt;br /&gt;
Every month we will be adding an "Easter Egg" to &lt;a href="http://www.falafel.com" target="blank"&gt;www.falafel.com&lt;/a&gt;. Just a little fun interactive element one might happen to stumble upon while clicking through the site.&lt;br /&gt; &lt;br /&gt;
Previous misadventures have included our rippling logo at the header, and the interactive robot on the&lt;a href="http://www.falafel.com/consulting/default.aspx" target="blank"&gt; Consulting Home Page&lt;/a&gt;.&lt;br /&gt; &lt;br /&gt;
So be on the lookout, you never know what you may find!&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=Qd_EPfOhKBU:IrGWh9kjsEM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=Qd_EPfOhKBU:IrGWh9kjsEM:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=Qd_EPfOhKBU:IrGWh9kjsEM:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?i=Qd_EPfOhKBU:IrGWh9kjsEM:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=Qd_EPfOhKBU:IrGWh9kjsEM:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FalafelBlogs/~4/Qd_EPfOhKBU" height="1" width="1"/&gt;</description>
      <link>http://feeds.falafel.com/~r/FalafelBlogs/~3/Qd_EPfOhKBU/It_s_a_little_early_for_Easter_but.aspx</link>
      <author>Matt Kurvin</author>
      <comments>http://blog.falafel.com/Blogs/10-08-05/It_s_a_little_early_for_Easter_but.aspx</comments>
      <guid isPermaLink="false">076b5fcf-c31d-4eea-a54f-41264693d18b</guid>
      <pubDate>Thu, 05 Aug 2010 22:30:01 GMT</pubDate>
    <feedburner:origLink>http://blog.falafel.com/Blogs/10-08-05/It_s_a_little_early_for_Easter_but.aspx</feedburner:origLink></item>
    <item>
      <title>Falafel Software Welcomes Drew Wells to Management Team</title>
      <description>Falafel Software is very happy to announce Drew Wells has joined the management team at Falafel Software as Vice President of Products and Acquisitions. Wells joins the team with extensive experience building strong and successful product companies. He comes to Falafel from AutomatedQA, recently renamed Smart Bear Software, where he served for six years as the company’s Chief Technology Officer. AutomatedQA/Smart Bear and Falafel Software partner to offer state of the art consulting and training on AutomatedQA product offerings like TestComplete.&lt;br /&gt; &lt;br /&gt;
“Drew’s addition to the team signals an added focus at Falafel to complete the pyramid of consulting and training with the ‘product’ edge”, said Lino Tadros, Falafel Software’s Chairman &amp;amp; CEO, “Drew’s tremendous talent, ethics and hard work are an incredible addition to Falafel and fit very well with our plans and direction into the future.”&lt;br /&gt; &lt;br /&gt;
“Falafel Software is a great company.”, said Wells, “Lino leads an amazing group of smart people with world-class expertise in software technology and business needs. They also care deeply about the human side of customer experience. It’s an honor to join them and help the company continue to grow.”&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=bF6OQYtcwKQ:K-_YNfz4_qo:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=bF6OQYtcwKQ:K-_YNfz4_qo:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=bF6OQYtcwKQ:K-_YNfz4_qo:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?i=bF6OQYtcwKQ:K-_YNfz4_qo:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=bF6OQYtcwKQ:K-_YNfz4_qo:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FalafelBlogs/~4/bF6OQYtcwKQ" height="1" width="1"/&gt;</description>
      <link>http://feeds.falafel.com/~r/FalafelBlogs/~3/bF6OQYtcwKQ/Falafel_Software_Welcomes_Drew_Wells_to_Management_Team.aspx</link>
      <author>Lino Tadros</author>
      <comments>http://blog.falafel.com/Blogs/10-08-02/Falafel_Software_Welcomes_Drew_Wells_to_Management_Team.aspx</comments>
      <guid isPermaLink="false">85cd4b14-1860-4146-93d3-f210e7080923</guid>
      <pubDate>Mon, 02 Aug 2010 13:00:00 GMT</pubDate>
    <feedburner:origLink>http://blog.falafel.com/Blogs/10-08-02/Falafel_Software_Welcomes_Drew_Wells_to_Management_Team.aspx</feedburner:origLink></item>
    <item>
      <title>Binding a TextBlock&amp;rsquo;s ToolTip to its Own Text Property in Silverlight</title>
      <description>&lt;p&gt;There’s not always enough room in the UI to display the entire contents of a TextBlock.&amp;nbsp; Silverlight 4 includes the a new TextTrimming feature that allows you to cut a TextBlock’s content off after the last word that fits plus an ellipsis (. . .) at the end.&lt;/p&gt; &lt;p&gt;When I use the new text trimming feature, I like to put the un-trimmed contents of the TextBlock into its ToolTip so that the user can still see it when they mouse over the control.&lt;/p&gt; &lt;p&gt;The example below shows you how you can wire a TextBlock’s ToolTip to be bound to its own Text property.&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ca4d2dc0-ebea-4834-95ed-ce301672afbb" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: 1px  solid  #000080;color: #000000; font-family: 'courier new', courier, monospace; font-size: 10pt;"&gt; &lt;div style="background-color: #f8f8f8; max-height: 500px; overflow-x: auto; overflow-y: auto; padding-top: 2px; padding-right: 5px; padding-bottom: 2px; padding-left: 5px; white-space: nowrap;"&gt;&lt;span style="color: #0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515;"&gt;TextBlock&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; x&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;:&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;Name&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="tbSample"&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Text&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="Too long to fit the space you have available"&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #ff0000;"&gt;ToolTipService.ToolTip&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515;"&gt;Binding&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Path&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;=Text,&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; RelativeSource&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;={&lt;/span&gt;&lt;span style="color: #a31515;"&gt;RelativeSource&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; Self}}&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;"&lt;/span&gt;&lt;br /&gt; &lt;span style="color: #ff0000;"&gt;TextWrapping&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="NoWrap"&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; TextTrimming&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="WordEllipsis"&lt;/span&gt;&lt;span style="color: #ff0000;"&gt; HorizontalAlignment&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;="Stretch" /&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=54g5gMcPpfE:YNd_8fyhtLs:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=54g5gMcPpfE:YNd_8fyhtLs:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=54g5gMcPpfE:YNd_8fyhtLs:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?i=54g5gMcPpfE:YNd_8fyhtLs:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=54g5gMcPpfE:YNd_8fyhtLs:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FalafelBlogs/~4/54g5gMcPpfE" height="1" width="1"/&gt;</description>
      <link>http://feeds.falafel.com/~r/FalafelBlogs/~3/54g5gMcPpfE/Binding_a_TextBlock_rsquo_s_ToolTip_to_its_Own_Text_Property_in_Silverlight.aspx</link>
      <author>J. Tower</author>
      <comments>http://blog.falafel.com/Blogs/10-07-29/Binding_a_TextBlock_rsquo_s_ToolTip_to_its_Own_Text_Property_in_Silverlight.aspx</comments>
      <guid isPermaLink="false">5197afdd-0dfd-495f-b779-40b172c8850e</guid>
      <pubDate>Thu, 29 Jul 2010 21:05:17 GMT</pubDate>
    <feedburner:origLink>http://blog.falafel.com/Blogs/10-07-29/Binding_a_TextBlock_rsquo_s_ToolTip_to_its_Own_Text_Property_in_Silverlight.aspx</feedburner:origLink></item>
    <item>
      <title>Falafel Is Ready for TestComplete 8</title>
      <description>&lt;p&gt;Congratulations to our friends and partners at SmartBear for releasing the heavily anticipated release of TestComplete 8 to the market.&amp;nbsp; TestComplete 8 comes with an abundance of new features &lt;a href="http://www.automatedqa.com/products/testcomplete/whats-new/8-0/"&gt;(over 150 features&lt;/a&gt;) to make everyday testing of Software easier and enjoyable.&lt;/p&gt; &lt;p&gt;Falafel Software simultaneously released today two major revisions of its award winning series of courseware material for TestComplete&amp;nbsp; 8 Made Easy – Scripting Edition and the TestComplete 8 Made Easier – Keyword Edition.&lt;/p&gt; &lt;p&gt;You can order Testcomplete 8 Standard or Enterprise or upgrade your current version and receive 10% of the current price from the &lt;a href="http://store.falafel.com/p-27-testcomplete-8.aspx"&gt;Falafel Store&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Falafel software is offering TestComplete 8 training starting immediately on Scripting and Keyword testing, please check &lt;a href="http://www.falafel.com/testcomplete/testcomplete_services.aspx"&gt;the schedule&lt;/a&gt; for online and onsite classes.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Last but not least, if you would like to get your hand on the courseware material for these two classes, they available for purchase on Lulu.com &lt;/p&gt; &lt;p&gt;&lt;a href="http://www.lulu.com/product/12037404"&gt;Testcomplete 8 Made Easy – Scripting edition&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.lulu.com/product/12037468"&gt;TestComplete 8 Made Easier – Keyword Edition&lt;/a&gt;&lt;/p&gt; &lt;p&gt;With this release we also enabled PDF download from Lulu.com for these two books for a reduced price.&lt;/p&gt; &lt;p&gt;If you are an iPad user, check out the Keyword version of the book for the iBookStore that can be purchased &lt;a href="http://www.lulu.com/product/12037959"&gt;here&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&lt;img style="display: inline; margin-left: 0px; margin-right: 0px;" alt="TestComplete 8" src="http://www.falafel.com/images/tc8_online_home.jpg" /&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=YiQvzJTS00Y:jobxiOghPHM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=YiQvzJTS00Y:jobxiOghPHM:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=YiQvzJTS00Y:jobxiOghPHM:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?i=YiQvzJTS00Y:jobxiOghPHM:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=YiQvzJTS00Y:jobxiOghPHM:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FalafelBlogs/~4/YiQvzJTS00Y" height="1" width="1"/&gt;</description>
      <link>http://feeds.falafel.com/~r/FalafelBlogs/~3/YiQvzJTS00Y/Falafel_Is_Ready_for_TestComplete_8.aspx</link>
      <author>Lino Tadros</author>
      <comments>http://blog.falafel.com/Blogs/10-07-28/Falafel_Is_Ready_for_TestComplete_8.aspx</comments>
      <guid isPermaLink="false">15dadd0d-f9de-4b83-9bc3-acd67b7937cf</guid>
      <pubDate>Thu, 29 Jul 2010 00:00:00 GMT</pubDate>
    <feedburner:origLink>http://blog.falafel.com/Blogs/10-07-28/Falafel_Is_Ready_for_TestComplete_8.aspx</feedburner:origLink></item>
    <item>
      <title>Falafel 2 Go now available in the Apple iTunes App Store</title>
      <description>&lt;p&gt;&amp;nbsp;The Falafel Mobile Team is pleased to announce that Falafel 2 Go is now available in the App Store for the iPhone, iPad and iPod Touch.&amp;nbsp; This application joins its’ Android cousin (already available in the Android Market) as a solution which allows our customers to view our upcoming training schedule, quickly view our Twitter Tweets, or read our excellent technical blogs – all very easily from their mobile devices.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;a href="http://itunes.com/apps/falafelsoftwareinc"&gt;http://itunes.com/apps/falafelsoftwareinc&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Falafel 2 Go is a “universal application” where the same binary runs on the iPhone, iPod Touch, and the iPad in native resolution.&amp;nbsp; This is a preferred way to go as you (and your users) only need to manage a single binary, while still taking advantage of the additional capabilities of something like the iPad.&amp;nbsp; More technical blogs will be coming soon on this topic.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h2&gt;Take your data “2 Go”&lt;/h2&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Very soon, if not already, your customers and employees will be demanding to have access to various information on the go.&amp;nbsp; We can tell you from experience that there is more to this than just coding for a mobile device.&amp;nbsp; Of course there are all of the mobile considerations; such as the small form factor, limited battery life, reduced CPU power and memory capacities.&amp;nbsp; However, in the enterprise world, it is also all about tying into existing infrastructure.&amp;nbsp; Very seldom, an enterprise mobile app will be standalone, it will need to access existing information from other databases, systems, and applications.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;At Falafel, we feel we are uniquely positioned for maximum success in this area, as we have extensive experience building and maintaining back-end application infrastructures, as well as a state-of-the-art mobile team.&amp;nbsp; If you need help with your “2 Go” orders, please give us a call.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h2&gt;Silicon Valley Code Camp 2010&lt;/h2&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;One exciting example of our ability to do the above, is what we will be doing for the Silicon Valley Code Camp.&amp;nbsp; Code Camp is a 2 day, free, developer conference covering many development technologies, with currently over 100 technical sessions and 700+ attendees.&amp;nbsp; More information can be found at:&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.siliconvalley-codecamp.com"&gt;http://www.siliconvalley-codecamp.com&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;In addition to being a Platinum Sponsor, and having multiple speakers delivering many sessions, Falafel will be developing a mobile app for the conference which will enable attendees to view and manage info about sessions, tracks, rooms, and speakers – enriching their conference experience.&amp;nbsp; The mobile app will be making OData RESTful&amp;nbsp; calls to the backend Code Camp .NET application.&amp;nbsp; You may also see this running on multiple mobile platforms and examples from this solution being used in some of the Falafel talks being given at the conference.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=RQZYGIpKv4U:SixBNar8cug:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=RQZYGIpKv4U:SixBNar8cug:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=RQZYGIpKv4U:SixBNar8cug:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?i=RQZYGIpKv4U:SixBNar8cug:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=RQZYGIpKv4U:SixBNar8cug:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FalafelBlogs/~4/RQZYGIpKv4U" height="1" width="1"/&gt;</description>
      <link>http://feeds.falafel.com/~r/FalafelBlogs/~3/RQZYGIpKv4U/Falafel_2_Go_now_available_in_the_Apple_iTunes_App_Store.aspx</link>
      <author>Lance Bullock</author>
      <comments>http://blog.falafel.com/Blogs/10-07-27/Falafel_2_Go_now_available_in_the_Apple_iTunes_App_Store.aspx</comments>
      <guid isPermaLink="false">b47b8dda-9f11-466d-9d56-404f7c64040e</guid>
      <pubDate>Tue, 27 Jul 2010 17:31:29 GMT</pubDate>
    <feedburner:origLink>http://blog.falafel.com/Blogs/10-07-27/Falafel_2_Go_now_available_in_the_Apple_iTunes_App_Store.aspx</feedburner:origLink></item>
    <item>
      <title>Using a non converter to help you debug binding issues</title>
      <description>&lt;p&gt;Most of the time it’s not a big deal knowing what the binding source is. However when you have to go searching for that source with calls like RelativeSource then you’re not always sure of what you’re getting, if anything. I’ve found using a simple non converter can help a great deal. Let’s say you have a binding in xaml that looks something like this.&lt;/p&gt; &lt;div class="csharpcode"&gt; &lt;div style="overflow-y: auto;border: #7f9db9 1px solid;" class="reCodeBlock"&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;DataContext="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:SomeType}}}"&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;style type="text/css"&gt;
    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }
&lt;/style&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;If you’re not getting what you’re expecting in the DataContext, you can use a simple non converter to figure out what you’re getting.&lt;/p&gt; &lt;div style="overflow-y: auto;border: #7f9db9 1px solid;" class="reCodeBlock"&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;public&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;class&lt;/code&gt; &lt;code style="color: #000;"&gt;NonConverter : IValueConverter&amp;nbsp; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;{&amp;nbsp; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: gray;"&gt;#region IValueConverter Members &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;public&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;object&lt;/code&gt; &lt;code style="color: #000;"&gt;Convert(&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;object&lt;/code&gt; &lt;code style="color: #000;"&gt;value, Type targetType, &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;object&lt;/code&gt; &lt;code style="color: #000;"&gt;parameter, System.Globalization.CultureInfo culture)&amp;nbsp; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: #000;"&gt;{&amp;nbsp; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;return&lt;/code&gt; &lt;code style="color: #000;"&gt;value;&amp;nbsp; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: #000;"&gt;} &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;public&lt;/code&gt; &lt;code style="color: #069; font-weight: bold;"&gt;object&lt;/code&gt; &lt;code style="color: #000;"&gt;ConvertBack(&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;object&lt;/code&gt; &lt;code style="color: #000;"&gt;value, Type targetType, &lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;object&lt;/code&gt; &lt;code style="color: #000;"&gt;parameter, System.Globalization.CultureInfo culture)&amp;nbsp; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: #000;"&gt;{&amp;nbsp; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #069; font-weight: bold;"&gt;return&lt;/code&gt; &lt;code style="color: #000;"&gt;value;&amp;nbsp; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: #000;"&gt;} &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: gray;"&gt;#endregion&amp;nbsp; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;}&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Insert this into your xaml and put a break point on the “return value; “ line in your non converter. &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;div class="csharpcode"&gt; &lt;pre&gt;&lt;div style="overflow-y: auto;border: #7f9db9 1px solid;" class="reCodeBlock"&gt;&lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;&amp;lt;&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;UserControl.Resources&lt;/code&gt;&lt;code style="color: #000;"&gt;&amp;gt; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: #000;"&gt;&amp;lt;&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;local:NonConverter&lt;/code&gt; &lt;code style="color: #808080;"&gt;x:Key&lt;/code&gt;&lt;code style="color: #000;"&gt;=&lt;/code&gt;&lt;code style="color: blue;"&gt;"nonConverter"&lt;/code&gt;&lt;code style="color: #000;"&gt;&amp;gt;&amp;lt;/&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;local:NonConverter&lt;/code&gt;&lt;code style="color: #000;"&gt;&amp;gt; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;&amp;lt;/&lt;/code&gt;&lt;code style="color: #069; font-weight: bold;"&gt;UserControl.Resources&lt;/code&gt;&lt;code style="color: #000;"&gt;&amp;gt; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;... &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="background-color: #fff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000;"&gt;DataContext="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:MyWindow}},&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span style="margin-left: 6px !important;"&gt;&lt;code style="color: #000;"&gt;Converter={StaticResource nonConverter}}"&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&amp;nbsp;&lt;/pre&gt; &lt;/div&gt; &lt;style type="text/css"&gt;
    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }
&lt;/style&gt; &lt;p&gt;Now you can run your program, and when the break point gets hit, you can query exactly what is getting passed to your binding.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=1Q6Awt8IB54:xnrqHY3-xP8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=1Q6Awt8IB54:xnrqHY3-xP8:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=1Q6Awt8IB54:xnrqHY3-xP8:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?i=1Q6Awt8IB54:xnrqHY3-xP8:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=1Q6Awt8IB54:xnrqHY3-xP8:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FalafelBlogs/~4/1Q6Awt8IB54" height="1" width="1"/&gt;</description>
      <link>http://feeds.falafel.com/~r/FalafelBlogs/~3/1Q6Awt8IB54/Using_a_non_converter_to_help_you_debug_binding_issues.aspx</link>
      <author>Bary Nusz</author>
      <comments>http://blog.falafel.com/Blogs/10-07-21/Using_a_non_converter_to_help_you_debug_binding_issues.aspx</comments>
      <guid isPermaLink="false">380593f5-cc6b-4b52-ac2a-75de26ac7248</guid>
      <pubDate>Thu, 22 Jul 2010 02:16:44 GMT</pubDate>
    <feedburner:origLink>http://blog.falafel.com/Blogs/10-07-21/Using_a_non_converter_to_help_you_debug_binding_issues.aspx</feedburner:origLink></item>
    <item>
      <title>Using BindingValidationError to Add Messages to a Validation Summary in Silverlight</title>
      <description>&lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;If you aren’t familiar with it, the ValidationSummary control in Silverlight automatically shows validation exceptions for any controls within its same container element.&amp;nbsp; That means if you add it to a grid or StackPanel that is full of bound controls, it will capture any validation exceptions from those bindings.&amp;nbsp; It also gives you all kinds of useful functionality, like taking you to the invalid control when clicking on an item, and even removing the message when the input is corrected.&lt;/p&gt; &lt;p&gt;For example, these two textboxes are bound to FirstName and MiddleInitial properties, and MiddleInitial is required to be a string no longer than 1 character.&lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-UsingBindingValidationErrortoAddErrorsto_1419C-image_4.sflb.ashx"&gt;&lt;img alt="" style="border: 0px;  display: inline;" src="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-UsingBindingValidationErrortoAddErrorsto_1419C-image_thumb_1.sflb.ashx" width="402" height="227" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;This works automatically, because the textboxes and the ValidationSummary are all inside the same layout grid.&lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-UsingBindingValidationErrortoAddErrorsto_1419C-image_6.sflb.ashx"&gt;&lt;img alt="" style="border: 0px;  display: inline;" src="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-UsingBindingValidationErrortoAddErrorsto_1419C-image_thumb_2.sflb.ashx" width="502" height="138" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;But, if for some reason, we have to move the ValidationSummary outside, to another grid:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-UsingBindingValidationErrortoAddErrorsto_1419C-image_8.sflb.ashx"&gt;&lt;img alt="" style="border: 0px;  display: inline;" src="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-UsingBindingValidationErrortoAddErrorsto_1419C-image_thumb_3.sflb.ashx" width="502" height="168" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt; Oh no!&amp;nbsp; The validation exceptions are no longer handled, and the ValidationSummary remains blank.&lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-UsingBindingValidationErrortoAddErrorsto_1419C-image_10.sflb.ashx"&gt;&lt;img alt="" style="border: 0px;  display: inline;" src="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-UsingBindingValidationErrortoAddErrorsto_1419C-image_thumb_4.sflb.ashx" width="402" height="222" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;That’s because the ValidationSummary always hooks into a certain event of its parent container, in order to handle any ValidationExceptions from sibling controls.&amp;nbsp; Luckily, we can use that same event to hook it back up again, even when it is outside the layout control.&lt;/p&gt; &lt;p&gt;The event is BindingValidationError, and it is triggered each time a ValidationException is thrown due to a binding setter, and also each time a&amp;nbsp; setter action makes a previously invalid input valid again.&amp;nbsp; So both the adding and the removal of ValidationSummaryItems can be handled in the same place.&amp;nbsp; Here we are handling the event on the grdDataEntry, or the grid containing our textbox controls.&amp;nbsp; You can use the Context property to set and find any messages that match a particular control.&lt;/p&gt; &lt;pre class="code"&gt;&lt;span style="color: blue;"&gt;private void &lt;/span&gt;grdDataEntry_BindingValidationError(&lt;span style="color: blue;"&gt;object &lt;/span&gt;sender, &lt;span style="color: #2b91af;"&gt;ValidationErrorEventArgs &lt;/span&gt;e)
{
    &lt;span style="color: blue;"&gt;if &lt;/span&gt;(e.Action == &lt;span style="color: #2b91af;"&gt;ValidationErrorEventAction&lt;/span&gt;.Added)
    {
        &lt;span style="color: #2b91af;"&gt;ValidationSummaryItem &lt;/span&gt;vsi = &lt;span style="color: blue;"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af;"&gt;ValidationSummaryItem&lt;/span&gt;() 
        { Message = e.Error.ErrorContent.ToString(), Context = e.OriginalSource };
        vsi.Sources.Add(
            &lt;span style="color: blue;"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af;"&gt;ValidationSummaryItemSource&lt;/span&gt;(&lt;span style="color: #2b91af;"&gt;String&lt;/span&gt;.Empty, e.OriginalSource &lt;span style="color: blue;"&gt;as &lt;/span&gt;&lt;span style="color: #2b91af;"&gt;Control&lt;/span&gt;));
        valSum.Errors.Add(vsi);
    }
    &lt;span style="color: blue;"&gt;else
    &lt;/span&gt;{
        &lt;span style="color: #2b91af;"&gt;ValidationSummaryItem &lt;/span&gt;valsumremove = 
            valSum.Errors.FirstOrDefault(v =&amp;gt; v.Context == e.OriginalSource);
        &lt;span style="color: blue;"&gt;if &lt;/span&gt;(valsumremove != &lt;span style="color: blue;"&gt;null&lt;/span&gt;)
        {
            valSum.Errors.Remove(valsumremove);
        }
    }
}&lt;/pre&gt; &lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Now the validation messages appear as the ValidationSummaryItems are added and removed.&amp;nbsp; An invalid entry into the MiddleInitial field shows up in my ValidationSummary:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-UsingBindingValidationErrortoAddErrorsto_1419C-image_2.sflb.ashx"&gt;&lt;img alt="" style="border: 0px;  display: inline;" src="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-UsingBindingValidationErrortoAddErrorsto_1419C-image_thumb.sflb.ashx" width="402" height="220" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;And when I correct the input, the message is removed!&lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-UsingBindingValidationErrortoAddErrorsto_1419C-image_12.sflb.ashx"&gt;&lt;img alt="" style="border: 0px;  display: inline;" src="http://blog.falafel.com/Libraries/MetaBlogLib/WindowsLiveWriter-UsingBindingValidationErrortoAddErrorsto_1419C-image_thumb_5.sflb.ashx" width="402" height="264" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;So, the ValidationSummary can indeed be completely functional even when you are unable to place it in the same container as your bound controls.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=ND7Vixx-nqg:s60-o9DKz5s:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=ND7Vixx-nqg:s60-o9DKz5s:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=ND7Vixx-nqg:s60-o9DKz5s:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?i=ND7Vixx-nqg:s60-o9DKz5s:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=ND7Vixx-nqg:s60-o9DKz5s:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FalafelBlogs/~4/ND7Vixx-nqg" height="1" width="1"/&gt;</description>
      <link>http://feeds.falafel.com/~r/FalafelBlogs/~3/ND7Vixx-nqg/Using_BindingValidationError_to_Add_Messages_to_a_Validation_Summary_in_Silverlight.aspx</link>
      <author>Rachel Hagerman</author>
      <comments>http://blog.falafel.com/Blogs/10-07-20/Using_BindingValidationError_to_Add_Messages_to_a_Validation_Summary_in_Silverlight.aspx</comments>
      <guid isPermaLink="false">fcf1965c-52b3-4763-904f-af257c2b41e3</guid>
      <pubDate>Wed, 21 Jul 2010 04:08:22 GMT</pubDate>
    <feedburner:origLink>http://blog.falafel.com/Blogs/10-07-20/Using_BindingValidationError_to_Add_Messages_to_a_Validation_Summary_in_Silverlight.aspx</feedburner:origLink></item>
    <item>
      <title>Using a Generic Custom Attached Property Part 2</title>
      <description>&lt;p&gt;In &lt;a href="http://blog.falafel.com/blogs/barynusz/10-06-10/Using_a_Generic_Custom_Attached_Property_Part_1.aspx" target="_blank"&gt;part 1&lt;/a&gt; I talked about our strongly typed GenericAttachedProperty&amp;lt;A&amp;gt; class that allows you to quickly attach any object or class to a UI element. This works great as long as you only need to store one int and/or one string and/or one TMyBigClass on the same element. To be able to attach more than one of a particular type to the same UI element we need to update our GenericAttachedProperty&amp;lt;A&amp;gt; class. The problem is that our GenericAttachedProperty&amp;lt;A&amp;gt; class uses the same dependency property name “Value” for all generic types.&lt;/p&gt; &lt;div class="csharpcode"&gt; &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; GenericAttachedProperty&amp;lt;T&amp;gt;&lt;/pre&gt; &lt;pre&gt;    {&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; DependencyProperty ValueProperty =&lt;/pre&gt; &lt;pre&gt;                DependencyProperty.RegisterAttached(&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="str"&gt;"Value"&lt;/span&gt;,&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(T),&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(GenericAttachedProperty&amp;lt;T&amp;gt;),&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;null&lt;/span&gt;);&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; T GetValue(DependencyObject d)&lt;/pre&gt; &lt;pre class="alt"&gt;        {&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;return&lt;/span&gt; (T)d.GetValue(ValueProperty);&lt;/pre&gt; &lt;pre class="alt"&gt;        }&lt;/pre&gt; &lt;pre&gt; &lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SetValue(DependencyObject d, T &lt;span class="kwrd"&gt;value&lt;/span&gt;)&lt;/pre&gt; &lt;pre&gt;        {&lt;/pre&gt; &lt;pre class="alt"&gt;            d.SetValue(ValueProperty, &lt;span class="kwrd"&gt;value&lt;/span&gt;);&lt;/pre&gt; &lt;pre&gt;        }&lt;/pre&gt; &lt;pre class="alt"&gt;    }&lt;/pre&gt; &lt;/div&gt; &lt;style type="text/css"&gt;
    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }
&lt;/style&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;If the types are different then you’re OK because the “Value” dependency property name is registered with the type of the parent. However, when you want to attach more than one of the same type of attached properties you can’t because you end up with the same “Value” dependency property and the same parent. Because you can’t have a static constructor, you can’t really pass in a different name for the attached property. The only option I could figure out to get around this problem was to make a new abstract type where you can pass in the owner type.&lt;/p&gt; &lt;div class="csharpcode"&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;abstract&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; GenericAttachedProperty&amp;lt;O, A&amp;gt;&lt;/pre&gt; &lt;pre&gt;    {&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; DependencyProperty ValueProperty =&lt;/pre&gt; &lt;pre&gt;                DependencyProperty.RegisterAttached(&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="str"&gt;"Value"&lt;/span&gt;,&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(A),&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(GenericAttachedProperty&amp;lt;O, A&amp;gt;),&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;null&lt;/span&gt;);&lt;/pre&gt; &lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; A GetValue(DependencyObject d)&lt;/pre&gt; &lt;pre class="alt"&gt;        {&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;return&lt;/span&gt; (A)d.GetValue(ValueProperty);&lt;/pre&gt; &lt;pre class="alt"&gt;        }&lt;/pre&gt; &lt;pre&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SetValue(DependencyObject d, A &lt;span class="kwrd"&gt;value&lt;/span&gt;)&lt;/pre&gt; &lt;pre&gt;        {&lt;/pre&gt; &lt;pre class="alt"&gt;            d.SetValue(ValueProperty, &lt;span class="kwrd"&gt;value&lt;/span&gt;);&lt;/pre&gt; &lt;pre&gt;        }&lt;/pre&gt; &lt;pre class="alt"&gt;    }&lt;/pre&gt; &lt;/div&gt; &lt;style type="text/css"&gt;
    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }
&lt;/style&gt; &lt;p&gt;So now when we need to attach two ints (or any other object or class) to the same element you just need to declare new classes for each instance of the dependency property type you want to attach. Something like this:&lt;/p&gt; &lt;div class="csharpcode"&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; LeftCountAttachedProperty : GenericAttachedProperty&amp;lt;LeftCountAttachedProperty, &lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt; { };&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; RightCountAttachedProperty : GenericAttachedProperty&amp;lt;RightCountAttachedProperty, &lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt; { };&lt;/pre&gt; &lt;/div&gt; &lt;style type="text/css"&gt;
    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }
&lt;/style&gt; &lt;p&gt;This works because now when the “Value” dependency property is registered, it’s being registered to different parent types (which is defined in the third parameter in the RegisterAttached call). Now you can attach multiple unique int to any UI element by using its own class. Those calls would look something like this:&lt;/p&gt; &lt;div class="csharpcode"&gt; &lt;pre class="alt"&gt; &lt;span class="preproc"&gt;#region&lt;/span&gt; Unique Int&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; LeftCountAttachedProperty_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)&lt;/pre&gt; &lt;pre class="alt"&gt;        {&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; count = LeftCountAttachedProperty.GetValue(textBlock1);&lt;/pre&gt; &lt;pre class="alt"&gt;            ++count;&lt;/pre&gt; &lt;pre&gt;            LeftCountAttachedProperty.SetValue(textBlock1, count);&lt;/pre&gt; &lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre&gt;            textBlock1.Text = String.Format(&lt;span class="str"&gt;"Left AttachedProperty: {0}"&lt;/span&gt;, count.ToString());&lt;/pre&gt; &lt;pre class="alt"&gt;        }&lt;/pre&gt; &lt;pre&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; RightCountAttachedProperty_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)&lt;/pre&gt; &lt;pre&gt;        {&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; count = RightCountAttachedProperty.GetValue(textBlock1);&lt;/pre&gt; &lt;pre&gt;            ++count;&lt;/pre&gt; &lt;pre class="alt"&gt;            RightCountAttachedProperty.SetValue(textBlock1, count);&lt;/pre&gt; &lt;pre&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre class="alt"&gt;            textBlock1.Text = String.Format(&lt;span class="str"&gt;"Right AttachedProperty: {0}"&lt;/span&gt;, count.ToString());&lt;/pre&gt; &lt;pre&gt;        }&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="preproc"&gt;#endregion&lt;/span&gt; &lt;/pre&gt; &lt;/div&gt; &lt;style type="text/css"&gt;
    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }
&lt;/style&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;So what about the fourth parameter in the RegisterAttached call. Can we use the PropertyMetadata parameter to set and use a PropertyChangedCallback event handler for our GenericAttachedProperty? Yes, but it does require another updated abstract class.&lt;/p&gt; &lt;p&gt;If we just update the RegisterAttached call with the proper PropertyMetadata parameter to call a PropertyChangedCallback event handler like so:&lt;/p&gt; &lt;div class="csharpcode"&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; DependencyProperty ValueProperty =&lt;/pre&gt; &lt;pre&gt;                DependencyProperty.RegisterAttached(&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="str"&gt;"Value"&lt;/span&gt;,&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(A),&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(GenericAttachedPropertyValueChanged&amp;lt;O, A&amp;gt;),&lt;/pre&gt; &lt;pre&gt;#&lt;span class="kwrd"&gt;if&lt;/span&gt; Silverlight&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; FrameworkPropertyMetadata(&lt;span class="kwrd"&gt;false&lt;/span&gt;, OnValueChanged));&lt;/pre&gt; &lt;pre&gt;#&lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; PropertyMetadata(&lt;span class="kwrd"&gt;new&lt;/span&gt; PropertyChangedCallback(OnValueChanged)));&lt;/pre&gt; &lt;pre&gt;#endif&lt;/pre&gt; &lt;/div&gt; &lt;style type="text/css"&gt;
    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }
&lt;/style&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Notice the #if to handle the differences between Silverlight and WPF. &lt;/p&gt; &lt;p&gt;The event handler OnValueChanged must be static and will be called upon a change to any attached property of the same type with the same parent type regardless of what UI element the attached property is attached. To handle this problem we must be able to store separate PropertyChangedCallback event handlers with the UI elements that you’re attaching properties to. First, we need to add a couple of static members to add and remove PropertyChangedCallback event handlers.&lt;/p&gt; &lt;div class="csharpcode"&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; AddValueChangedHandler(DependencyObject element, PropertyChangedCallback callback)&lt;/pre&gt; &lt;pre&gt;        {&lt;/pre&gt; &lt;pre class="alt"&gt;        }&lt;/pre&gt; &lt;pre&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; RemoveValueChangedHandler(DependencyObject element, PropertyChangedCallback callback)&lt;/pre&gt; &lt;pre&gt;        {&lt;/pre&gt; &lt;pre class="alt"&gt;        }&lt;/pre&gt; &lt;/div&gt; &lt;style type="text/css"&gt;
    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }
&lt;/style&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;We could just attach the callback event handler to the element with a call like this:&lt;/p&gt; &lt;div class="csharpcode"&gt; &lt;pre class="alt"&gt;GenericAttachedProperty&amp;lt;PropertyChangedCallback&amp;gt;.SetValue(element, callback);&lt;/pre&gt; &lt;/div&gt; &lt;style type="text/css"&gt;
    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }
&lt;/style&gt; &lt;p&gt;But this would only allow you to ever attach one event handler to any one element regardless of the owner type. So if you tried to add a event handler to a UI element named textBox1 with the LeftCountAttachedProperty from above and then attached another event handler to the same UI element with RightCountAttachedProperty from above, you would overwrite the first event handler with the second one because the event handlers are the same type. What we need is to store the event handlers in a Dictionary that is keyed with the owner type. So we need a new class declaration to handle this.&lt;/p&gt; &lt;div class="csharpcode"&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; GenericAttachedPropertyChangedCallbackDictionary :&lt;/pre&gt; &lt;pre&gt;        GenericAttachedProperty&amp;lt;GenericAttachedPropertyChangedCallbackDictionary, Dictionary&amp;lt;Type, PropertyChangedCallback&amp;gt;&amp;gt; { }&lt;/pre&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Now each UI element can maintain its own dictionary of event handler keyed with the owner type. Now we can fill in the Add/Remove members.&lt;/p&gt; &lt;div class="csharpcode"&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; Type _type = &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(O);&lt;/pre&gt; &lt;pre&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; AddValueChangedHandler(DependencyObject element, PropertyChangedCallback callback)&lt;/pre&gt; &lt;pre&gt;        {&lt;/pre&gt; &lt;pre class="alt"&gt;            Dictionary&amp;lt;Type, PropertyChangedCallback&amp;gt; propertyChangedCallbackDictionary =&lt;/pre&gt; &lt;pre&gt;                GenericAttachedPropertyChangedCallbackDictionary.GetValue(element);&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (propertyChangedCallbackDictionary == &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt; &lt;pre&gt;            {&lt;/pre&gt; &lt;pre class="alt"&gt;                propertyChangedCallbackDictionary = &lt;span class="kwrd"&gt;new&lt;/span&gt; Dictionary&amp;lt;Type, PropertyChangedCallback&amp;gt;();&lt;/pre&gt; &lt;pre&gt;                element.SetValue(GenericAttachedPropertyChangedCallbackDictionary.ValueProperty, propertyChangedCallbackDictionary);&lt;/pre&gt; &lt;pre class="alt"&gt;            }&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (propertyChangedCallbackDictionary.ContainsKey(_type))&lt;/pre&gt; &lt;pre class="alt"&gt;            {&lt;/pre&gt; &lt;pre&gt;                propertyChangedCallbackDictionary[_type] += callback;&lt;/pre&gt; &lt;pre class="alt"&gt;            }&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;/pre&gt; &lt;pre class="alt"&gt;            {&lt;/pre&gt; &lt;pre&gt;                propertyChangedCallbackDictionary[_type] = callback;&lt;/pre&gt; &lt;pre class="alt"&gt;            }&lt;/pre&gt; &lt;pre&gt;        }&lt;/pre&gt; &lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; RemoveValueChangedHandler(DependencyObject element, PropertyChangedCallback callback)&lt;/pre&gt; &lt;pre class="alt"&gt;        {&lt;/pre&gt; &lt;pre&gt;            Dictionary&amp;lt;Type, PropertyChangedCallback&amp;gt; propertyChangedCallbackDictionary =&lt;/pre&gt; &lt;pre class="alt"&gt;                GenericAttachedPropertyChangedCallbackDictionary.GetValue(element);&lt;/pre&gt; &lt;pre&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; ((propertyChangedCallbackDictionary != &lt;span class="kwrd"&gt;null&lt;/span&gt;) &amp;amp;&amp;amp;&lt;/pre&gt; &lt;pre&gt;                (propertyChangedCallbackDictionary.ContainsKey(_type)))&lt;/pre&gt; &lt;pre class="alt"&gt;            {&lt;/pre&gt; &lt;pre&gt;                propertyChangedCallbackDictionary[_type] -= callback;&lt;/pre&gt; &lt;pre class="alt"&gt;            }&lt;/pre&gt; &lt;pre&gt;        }&lt;/pre&gt; &lt;/div&gt; &lt;style type="text/css"&gt;
    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }
&lt;/style&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;The first thing we do with either call is retrieve the dictionary from the UI element. If the dictionary comes back null when adding an event handler, then it’s the first time we’re adding an event handler, and the dictionary must be created and attached to the element. We can then add the event handler to the dictionary with the owner type as a key.&lt;/p&gt; &lt;p&gt;Now we just need to fill in the static OnValueChanged event handler.&lt;/p&gt; &lt;div class="csharpcode"&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)&lt;/pre&gt; &lt;pre&gt;        {&lt;/pre&gt; &lt;pre class="alt"&gt;            Dictionary&amp;lt;Type, PropertyChangedCallback&amp;gt; propertyChangedCallbackDictionary =&lt;/pre&gt; &lt;pre&gt;                GenericAttachedPropertyChangedCallbackDictionary.GetValue(sender);&lt;/pre&gt; &lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; ((propertyChangedCallbackDictionary != &lt;span class="kwrd"&gt;null&lt;/span&gt;) &amp;amp;&amp;amp;&lt;/pre&gt; &lt;pre class="alt"&gt;                (propertyChangedCallbackDictionary.ContainsKey(_type)))&lt;/pre&gt; &lt;pre&gt;            {&lt;/pre&gt; &lt;pre class="alt"&gt;                PropertyChangedCallback callback = propertyChangedCallbackDictionary[_type];&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (callback != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt; &lt;pre class="alt"&gt;                {&lt;/pre&gt; &lt;pre&gt;                    callback(sender, e);&lt;/pre&gt; &lt;pre class="alt"&gt;                }&lt;/pre&gt; &lt;pre&gt;            }&lt;/pre&gt; &lt;pre class="alt"&gt;        }&lt;/pre&gt; &lt;/div&gt; &lt;style type="text/css"&gt;
    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }
&lt;/style&gt; &lt;p&gt;It’s a simple matter to retrieve the dictionary. Then the event handler keyed upon the owner type can be called. &lt;/p&gt; &lt;p&gt;The complete updated class is listed here.&lt;/p&gt; &lt;div class="csharpcode"&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; GenericAttachedPropertyChangedCallbackDictionary :&lt;/pre&gt; &lt;pre&gt;        GenericAttachedProperty&amp;lt;GenericAttachedPropertyChangedCallbackDictionary, Dictionary&amp;lt;Type, PropertyChangedCallback&amp;gt;&amp;gt; { }&lt;/pre&gt; &lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre&gt; &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="rem"&gt;/// A strongly typed generic attached property with property changed callback support&lt;/span&gt;&lt;/pre&gt; &lt;pre&gt; &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="rem"&gt;/// &amp;lt;typeparam name="O"&amp;gt;The type of the owner class&amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;/pre&gt; &lt;pre&gt; &lt;span class="rem"&gt;/// &amp;lt;typeparam name="A"&amp;gt;Type of the attached property&amp;lt;/typeparam&amp;gt;&lt;/span&gt;&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;abstract&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; GenericAttachedPropertyValueChanged&amp;lt;O, A&amp;gt;&lt;/pre&gt; &lt;pre&gt;    {&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; Type _type = &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(O);&lt;/pre&gt; &lt;pre&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; DependencyProperty ValueProperty =&lt;/pre&gt; &lt;pre&gt;                DependencyProperty.RegisterAttached(&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="str"&gt;"Value"&lt;/span&gt;,&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(A),&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(GenericAttachedPropertyValueChanged&amp;lt;O, A&amp;gt;),&lt;/pre&gt; &lt;pre&gt;&lt;span class="preproc"&gt;#if&lt;/span&gt; Silverlight&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; FrameworkPropertyMetadata(&lt;span class="kwrd"&gt;false&lt;/span&gt;, OnValueChanged));&lt;/pre&gt; &lt;pre&gt;&lt;span class="preproc"&gt;#else&lt;/span&gt;&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; PropertyMetadata(&lt;span class="kwrd"&gt;new&lt;/span&gt; PropertyChangedCallback(OnValueChanged)));&lt;/pre&gt; &lt;pre&gt;&lt;span class="preproc"&gt;#endif&lt;/span&gt;&lt;/pre&gt; &lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; A GetValue(DependencyObject d)&lt;/pre&gt; &lt;pre class="alt"&gt;        {&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;return&lt;/span&gt; (A)d.GetValue(ValueProperty);&lt;/pre&gt; &lt;pre class="alt"&gt;        }&lt;/pre&gt; &lt;pre&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SetValue(DependencyObject d, A &lt;span class="kwrd"&gt;value&lt;/span&gt;)&lt;/pre&gt; &lt;pre&gt;        {&lt;/pre&gt; &lt;pre class="alt"&gt;            d.SetValue(ValueProperty, &lt;span class="kwrd"&gt;value&lt;/span&gt;);&lt;/pre&gt; &lt;pre&gt;        }&lt;/pre&gt; &lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; AddValueChangedHandler(DependencyObject element, PropertyChangedCallback callback)&lt;/pre&gt; &lt;pre class="alt"&gt;        {&lt;/pre&gt; &lt;pre&gt;            Dictionary&amp;lt;Type, PropertyChangedCallback&amp;gt; propertyChangedCallbackDictionary =&lt;/pre&gt; &lt;pre class="alt"&gt;                GenericAttachedPropertyChangedCallbackDictionary.GetValue(element);&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (propertyChangedCallbackDictionary == &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt; &lt;pre class="alt"&gt;            {&lt;/pre&gt; &lt;pre&gt;                propertyChangedCallbackDictionary = &lt;span class="kwrd"&gt;new&lt;/span&gt; Dictionary&amp;lt;Type, PropertyChangedCallback&amp;gt;();&lt;/pre&gt; &lt;pre class="alt"&gt;                element.SetValue(GenericAttachedPropertyChangedCallbackDictionary.ValueProperty, propertyChangedCallbackDictionary);&lt;/pre&gt; &lt;pre&gt;            }&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (propertyChangedCallbackDictionary.ContainsKey(_type))&lt;/pre&gt; &lt;pre&gt;            {&lt;/pre&gt; &lt;pre class="alt"&gt;                propertyChangedCallbackDictionary[_type] += callback;&lt;/pre&gt; &lt;pre&gt;            }&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;/pre&gt; &lt;pre&gt;            {&lt;/pre&gt; &lt;pre class="alt"&gt;                propertyChangedCallbackDictionary[_type] = callback;&lt;/pre&gt; &lt;pre&gt;            }&lt;/pre&gt; &lt;pre class="alt"&gt;        }&lt;/pre&gt; &lt;pre&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; RemoveValueChangedHandler(DependencyObject element, PropertyChangedCallback callback)&lt;/pre&gt; &lt;pre&gt;        {&lt;/pre&gt; &lt;pre class="alt"&gt;            Dictionary&amp;lt;Type, PropertyChangedCallback&amp;gt; propertyChangedCallbackDictionary =&lt;/pre&gt; &lt;pre&gt;                GenericAttachedPropertyChangedCallbackDictionary.GetValue(element);&lt;/pre&gt; &lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; ((propertyChangedCallbackDictionary != &lt;span class="kwrd"&gt;null&lt;/span&gt;) &amp;amp;&amp;amp;&lt;/pre&gt; &lt;pre class="alt"&gt;                (propertyChangedCallbackDictionary.ContainsKey(_type)))&lt;/pre&gt; &lt;pre&gt;            {&lt;/pre&gt; &lt;pre class="alt"&gt;                propertyChangedCallbackDictionary[_type] -= callback;&lt;/pre&gt; &lt;pre&gt;            }&lt;/pre&gt; &lt;pre class="alt"&gt;        }&lt;/pre&gt; &lt;pre&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)&lt;/pre&gt; &lt;pre&gt;        {&lt;/pre&gt; &lt;pre class="alt"&gt;            Dictionary&amp;lt;Type, PropertyChangedCallback&amp;gt; propertyChangedCallbackDictionary =&lt;/pre&gt; &lt;pre&gt;                GenericAttachedPropertyChangedCallbackDictionary.GetValue(sender);&lt;/pre&gt; &lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; ((propertyChangedCallbackDictionary != &lt;span class="kwrd"&gt;null&lt;/span&gt;) &amp;amp;&amp;amp;&lt;/pre&gt; &lt;pre class="alt"&gt;                (propertyChangedCallbackDictionary.ContainsKey(_type)))&lt;/pre&gt; &lt;pre&gt;            {&lt;/pre&gt; &lt;pre class="alt"&gt;                PropertyChangedCallback callback = propertyChangedCallbackDictionary[_type];&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (callback != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;/pre&gt; &lt;pre class="alt"&gt;                {&lt;/pre&gt; &lt;pre&gt;                    callback(sender, e);&lt;/pre&gt; &lt;pre class="alt"&gt;                }&lt;/pre&gt; &lt;pre&gt;            }&lt;/pre&gt; &lt;pre class="alt"&gt;        }&lt;/pre&gt; &lt;pre&gt;    }&lt;/pre&gt; &lt;/div&gt; &lt;style type="text/css"&gt;
    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }
&lt;/style&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;To demonstrate the various generic classes, I’ve prepared a sample Silverlight application &lt;a href="http://panhandleskies.com/Blog/GenericAttachedPropertyDemoTestPage.html" target="_blank"&gt;here&lt;/a&gt;. &lt;/p&gt; &lt;p&gt;All the attached properties in this demo are attached to the same UI element – textBlock1. &lt;/p&gt; &lt;p&gt;The buttons labeled “Left Int” and “Right Int” have the following click event handlers.&lt;/p&gt; &lt;div class="csharpcode"&gt; &lt;pre class="alt"&gt; &lt;span class="preproc"&gt;#region&lt;/span&gt; Basic Int Type&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; LeftIntCount_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)&lt;/pre&gt; &lt;pre class="alt"&gt;        {&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; count = GenericAttachedProperty&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt;.GetValue(textBlock1);&lt;/pre&gt; &lt;pre class="alt"&gt;            ++count;&lt;/pre&gt; &lt;pre&gt;            GenericAttachedProperty&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt;.SetValue(textBlock1, count);&lt;/pre&gt; &lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre&gt;            textBlock1.Text = String.Format(&lt;span class="str"&gt;"Left Int: {0}"&lt;/span&gt;, count.ToString());&lt;/pre&gt; &lt;pre class="alt"&gt;        }&lt;/pre&gt; &lt;pre&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; RightIntCount_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)&lt;/pre&gt; &lt;pre&gt;        {&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; count = GenericAttachedProperty&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt;.GetValue(textBlock1);&lt;/pre&gt; &lt;pre&gt;            ++count;&lt;/pre&gt; &lt;pre class="alt"&gt;            GenericAttachedProperty&amp;lt;&lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt;.SetValue(textBlock1, count);&lt;/pre&gt; &lt;pre&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre class="alt"&gt;            textBlock1.Text = String.Format(&lt;span class="str"&gt;"Right Int: {0}"&lt;/span&gt;, count.ToString());&lt;/pre&gt; &lt;pre&gt;        }&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="preproc"&gt;#endregion&lt;/span&gt;&lt;/pre&gt; &lt;/div&gt; &lt;style type="text/css"&gt;
    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }
&lt;/style&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Clicking either button will first call GetValue of the generic class. The generic type we are looking for is an int, and we are looking for it in the textBlock1 element. The int value is incremented, and the new value is attached back to the textBlock1 element. The new value is then displayed on the textBlock1 element. By clicking both buttons, it becomes obvious that the same value is being read, incremented, and reattached regardless of whether the left or right button is clicked. &lt;/p&gt; &lt;p&gt;For the next part of the demo, we need to declare a couple of classes to handle two unique int attached properties.&lt;/p&gt; &lt;div class="csharpcode"&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; LeftCountAttachedProperty : GenericAttachedProperty&amp;lt;LeftCountAttachedProperty, &lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt; { };&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; RightCountAttachedProperty : GenericAttachedProperty&amp;lt;RightCountAttachedProperty, &lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt; { };&lt;/pre&gt; &lt;/div&gt; &lt;style type="text/css"&gt;
    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }
&lt;/style&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;The buttons labeled “Left Count” and “Right Count” have the following click event handlers:&lt;/p&gt; &lt;div class="csharpcode"&gt; &lt;pre class="alt"&gt; &lt;span class="preproc"&gt;#region&lt;/span&gt; Unique Int&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; LeftCountAttachedProperty_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)&lt;/pre&gt; &lt;pre class="alt"&gt;        {&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; count = LeftCountAttachedProperty.GetValue(textBlock1);&lt;/pre&gt; &lt;pre class="alt"&gt;            ++count;&lt;/pre&gt; &lt;pre&gt;            LeftCountAttachedProperty.SetValue(textBlock1, count);&lt;/pre&gt; &lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre&gt;            textBlock1.Text = String.Format(&lt;span class="str"&gt;"Left AttachedProperty: {0}"&lt;/span&gt;, count.ToString());&lt;/pre&gt; &lt;pre class="alt"&gt;        }&lt;/pre&gt; &lt;pre&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; RightCountAttachedProperty_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)&lt;/pre&gt; &lt;pre&gt;        {&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; count = RightCountAttachedProperty.GetValue(textBlock1);&lt;/pre&gt; &lt;pre&gt;            ++count;&lt;/pre&gt; &lt;pre class="alt"&gt;            RightCountAttachedProperty.SetValue(textBlock1, count);&lt;/pre&gt; &lt;pre&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre class="alt"&gt;            textBlock1.Text = String.Format(&lt;span class="str"&gt;"Right AttachedProperty: {0}"&lt;/span&gt;, count.ToString());&lt;/pre&gt; &lt;pre&gt;        }&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="preproc"&gt;#endregion&lt;/span&gt; &lt;/pre&gt; &lt;/div&gt; &lt;style type="text/css"&gt;
    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }
&lt;/style&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Same routine as before except that we are using our unique classes to store unique int values. Clicking either button will demonstrate that the values are indeed unique.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;For the last part of the demo, we need to declare our unique callback classes.&lt;/p&gt; &lt;div class="csharpcode"&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; LeftCountAttachedCallbackProperty : GenericAttachedPropertyValueChanged&amp;lt;LeftCountAttachedProperty, &lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt; { };&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; RightCountAttachedCallbackProperty : GenericAttachedPropertyValueChanged&amp;lt;RightCountAttachedProperty, &lt;span class="kwrd"&gt;int&lt;/span&gt;&amp;gt; { };&lt;/pre&gt; &lt;/div&gt; &lt;style type="text/css"&gt;
    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }
&lt;/style&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;The event handlers for the CheckBox, the unique PropertyChangedCallbacks, and the buttons labeled “Left Count Callback” and “Right Count Callback” are as follows.&lt;/p&gt; &lt;div class="csharpcode"&gt; &lt;pre class="alt"&gt; &lt;span class="preproc"&gt;#region&lt;/span&gt; Unique Int with Callback&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; CheckBox_Checked(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)&lt;/pre&gt; &lt;pre class="alt"&gt;        {&lt;/pre&gt; &lt;pre&gt;            LeftCountAttachedCallbackProperty.AddValueChangedHandler(textBlock1, OnLeftValueChanged);&lt;/pre&gt; &lt;pre class="alt"&gt;            RightCountAttachedCallbackProperty.AddValueChangedHandler(textBlock1, OnRightValueChanged);&lt;/pre&gt; &lt;pre&gt;        }&lt;/pre&gt; &lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; CheckBox_Unchecked(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)&lt;/pre&gt; &lt;pre class="alt"&gt;        {&lt;/pre&gt; &lt;pre&gt;            LeftCountAttachedCallbackProperty.RemoveValueChangedHandler(textBlock1, OnLeftValueChanged);&lt;/pre&gt; &lt;pre class="alt"&gt;            RightCountAttachedCallbackProperty.RemoveValueChangedHandler(textBlock1, OnRightValueChanged);&lt;/pre&gt; &lt;pre&gt;            leftTextBlock.Text = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty;&lt;/pre&gt; &lt;pre class="alt"&gt;            rightTextBlock.Text = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty;&lt;/pre&gt; &lt;pre&gt;        }&lt;/pre&gt; &lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; LeftCountAttachedPropertyCallback_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)&lt;/pre&gt; &lt;pre class="alt"&gt;        {&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; count = LeftCountAttachedCallbackProperty.GetValue(textBlock1);&lt;/pre&gt; &lt;pre class="alt"&gt;            ++count;&lt;/pre&gt; &lt;pre&gt;            LeftCountAttachedCallbackProperty.SetValue(textBlock1, count);&lt;/pre&gt; &lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre&gt;            textBlock1.Text = String.Format(&lt;span class="str"&gt;"Left Callback: {0}"&lt;/span&gt;, count.ToString());&lt;/pre&gt; &lt;pre class="alt"&gt;        }&lt;/pre&gt; &lt;pre&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; RightCountAttachedPropertyCallback_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, RoutedEventArgs e)&lt;/pre&gt; &lt;pre&gt;        {&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; count = RightCountAttachedCallbackProperty.GetValue(textBlock1);&lt;/pre&gt; &lt;pre&gt;            ++count;&lt;/pre&gt; &lt;pre class="alt"&gt;            RightCountAttachedCallbackProperty.SetValue(textBlock1, count);&lt;/pre&gt; &lt;pre&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre class="alt"&gt;            textBlock1.Text = String.Format(&lt;span class="str"&gt;"Right Callback: {0}"&lt;/span&gt;, count.ToString());&lt;/pre&gt; &lt;pre&gt;        }&lt;/pre&gt; &lt;pre class="alt"&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnLeftValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)&lt;/pre&gt; &lt;pre class="alt"&gt;        {&lt;/pre&gt; &lt;pre&gt;            leftTextBlock.Text = e.NewValue.ToString();&lt;/pre&gt; &lt;pre class="alt"&gt;        }&lt;/pre&gt; &lt;pre&gt;&amp;nbsp;&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnRightValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)&lt;/pre&gt; &lt;pre&gt;        {&lt;/pre&gt; &lt;pre class="alt"&gt;            rightTextBlock.Text = e.NewValue.ToString();&lt;/pre&gt; &lt;pre&gt;        }&lt;/pre&gt; &lt;pre class="alt"&gt; &lt;span class="preproc"&gt;#endregion&lt;/span&gt;&lt;/pre&gt; &lt;/div&gt; &lt;style type="text/css"&gt;
    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }
&lt;/style&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;The PropertyChangedCallback event handlers are set and unset by the CheckBox. Clicking the left and right buttons demonstrates that the values are unique and the event handlers are unique.&lt;/p&gt; &lt;p&gt;It’s important to remember that you can attach any class or object type to any UI element. Using these generic classes you can quickly attach whatever you may need to UI elements and even use the PropertyChangedCallback to those attached properties however you need.&lt;/p&gt; &lt;p&gt;I’ve included the generic classes into a solution that contains a Silverlight project and WPF project that share the same source code as well as the demo solution &lt;a href="http://blog.falafel.com/Files/BaryNusz/BlogFalafelUtil.zip" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=eZsgxH-5luA:W8-UXwno5ts:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=eZsgxH-5luA:W8-UXwno5ts:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=eZsgxH-5luA:W8-UXwno5ts:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?i=eZsgxH-5luA:W8-UXwno5ts:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=eZsgxH-5luA:W8-UXwno5ts:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FalafelBlogs/~4/eZsgxH-5luA" height="1" width="1"/&gt;</description>
      <link>http://feeds.falafel.com/~r/FalafelBlogs/~3/eZsgxH-5luA/Using_a_Generic_Custom_Attached_Property_Part_2.aspx</link>
      <author>Bary Nusz</author>
      <comments>http://blog.falafel.com/Blogs/10-07-14/Using_a_Generic_Custom_Attached_Property_Part_2.aspx</comments>
      <guid isPermaLink="false">367b0329-a402-4b5d-91b5-800ab758ca58</guid>
      <pubDate>Wed, 14 Jul 2010 17:07:56 GMT</pubDate>
    <feedburner:origLink>http://blog.falafel.com/Blogs/10-07-14/Using_a_Generic_Custom_Attached_Property_Part_2.aspx</feedburner:origLink></item>
    <item>
      <title>Sitefinity WebUIEditors and Selectors</title>
      <description>&lt;p&gt;Still as of Sitefinity 3.7 SP3, it is still really hard to find out all the available WebUIEditors and Selectors available for Sitefinity properties during Custom Control Development.&lt;/p&gt; &lt;p&gt;With some snooping around using .NET Reflector, you could see they are all over the place.&amp;nbsp; Most of them are undocumented so be careful :)&lt;/p&gt; &lt;p&gt;These are the 20 WebUIEditors and Selectors currently found in the shipping 3.7 SP3:&lt;/p&gt; &lt;p&gt;Telerik.Blogs.WebControls.BlogsSelector   &lt;br /&gt;
Telerik.Cms.Engine.WebControls.Categories.CategoriesSelector    &lt;br /&gt;
Telerik.Cms.Engine.WebControls.ContentSelector    &lt;br /&gt;
Telerik.Cms.Engine.WebControls.HtmlContentEditor    &lt;br /&gt;
Telerik.Cms.Engine.WebControls.RssContentSelector    &lt;br /&gt;
Telerik.Cms.Engine.WebControls.Tags.TagSelector    &lt;br /&gt;
Telerik.Cms.Web.UI.CmsUrlWebEditor    &lt;br /&gt;
Telerik.Cms.Web.UI.DhlIdEditor    &lt;br /&gt;
Telerik.FileManager.UrlWebEditor    &lt;br /&gt;
Telerik.Libraries.WebControls.DocumentsSelector    &lt;br /&gt;
Telerik.Libraries.WebControls.DownloadListSelector    &lt;br /&gt;
Telerik.Libraries.WebControls.GallerySelector    &lt;br /&gt;
Telerik.Libraries.WebControls.ImageSelector    &lt;br /&gt;
Telerik.Libraries.WebControls.LibrarySelector    &lt;br /&gt;
Telerik.Lists.WebControls.ListSelector    &lt;br /&gt;
Telerik.News.WebControls.NewsSelector    &lt;br /&gt;
Telerik.Notifications.Newsletters.WebControl.GroupSelectionList    &lt;br /&gt;
Telerik.Polls.WebControls.PollBoxEditor    &lt;br /&gt;
Telerik.Rss.WebControls.RssFeedSelector    &lt;br /&gt;
Telerik.Search.WebControls.IndexingServicesPicker&lt;/p&gt; &lt;p&gt;These are the class names with their full namespace that needs to be used in the attribute before your properties as well as the assemblies they come from. So for example, if you want to decorate a property with the ListSelector, this will be the syntax:&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;div class="reCodeBlock" style="border: 1px  solid  #7f9db9;overflow-y: auto;"&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000000;"&gt;[WebEditor(&lt;/code&gt;&lt;code style="color: blue;"&gt;"Telerik.Lists.WebControls.ListSelector, Telerik.Lists"&lt;/code&gt;&lt;code style="color: #000000;"&gt;)]&amp;nbsp; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;public&lt;/code&gt; &lt;code style="color: #006699; font-weight: bold;"&gt;string&lt;/code&gt; &lt;code style="color: #000000;"&gt;QuoteList &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000000;"&gt;{ &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 15px !important;"&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;get&lt;/code&gt; &lt;code style="color: #000000;"&gt;{ &lt;/code&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;return&lt;/code&gt; &lt;code style="color: #000000;"&gt;_QuoteList; } &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 15px !important;"&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;set&lt;/code&gt; &lt;code style="color: #000000;"&gt;{ _QuoteList = value; } &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000000;"&gt;}&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=m_X4QQU2n9g:MC-4fQ7GUSA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=m_X4QQU2n9g:MC-4fQ7GUSA:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=m_X4QQU2n9g:MC-4fQ7GUSA:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?i=m_X4QQU2n9g:MC-4fQ7GUSA:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=m_X4QQU2n9g:MC-4fQ7GUSA:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FalafelBlogs/~4/m_X4QQU2n9g" height="1" width="1"/&gt;</description>
      <link>http://feeds.falafel.com/~r/FalafelBlogs/~3/m_X4QQU2n9g/Sitefinity_WebUIEditors_and_Selectors.aspx</link>
      <author>Lino Tadros</author>
      <comments>http://blog.falafel.com/Blogs/10-07-09/Sitefinity_WebUIEditors_and_Selectors.aspx</comments>
      <guid isPermaLink="false">27617a32-c094-4c67-a3a0-bb0d003bb874</guid>
      <pubDate>Fri, 09 Jul 2010 18:38:00 GMT</pubDate>
    <feedburner:origLink>http://blog.falafel.com/Blogs/10-07-09/Sitefinity_WebUIEditors_and_Selectors.aspx</feedburner:origLink></item>
    <item>
      <title>iPad UISplitViewController bug &amp;ndash; a workaround</title>
      <description>&lt;p&gt;&lt;span style="font-weight: bold; font-size: 24px;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;h4&gt;The Problem&lt;/h4&gt; &lt;p&gt;&lt;br /&gt; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;The UISplitViewController is the flagship iPad user interface element, as it allows your application to optimize the use of the large screen.&amp;nbsp; This control manages 2 views, usually a master view (for navigation) and a detail view (for content).&amp;nbsp; When in landscape mode, the controller shows both views side-by-side, and when the device is rotated to portrait mode, the master view is hidden and the detail view occupies the full screen.&amp;nbsp; In this case, the SplitView controller places the master view in a hidden UIPopoverController, and the common MO is to add a button to a toolbar on the detail view so the user can call up the hidden master view for navigation – when in landscape this toolbar button is unnecessary (because the view is already showing) and should be hidden.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;When testing the forthcoming Falafel 2 Go iPad version, I sometimes encountered a case where after the rotation back to portrait the toolbar button was missing.&amp;nbsp; This is a pretty bad user experience because now the user is looking at detail view content, with no way to navigate – aside from rotating the device again.&amp;nbsp; Of course I looked at my code first, and all seemed ok:&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;[toolbar setItems:items animated:YES]; &lt;/p&gt; &lt;p&gt;&amp;nbsp; &lt;/p&gt; &lt;p&gt;This should correctly set the item back on the UIToolbar inside of the &lt;em&gt;splitViewController:willHideViewController:withButtonBarItem:forPopoverController:&lt;/em&gt; delegate method.&amp;nbsp; &lt;/p&gt; &lt;p&gt;&amp;nbsp; &lt;/p&gt; &lt;p&gt;After discovering that I could easily reproduce this problem by starting in portrait, rotating the device 45 degrees until the view started to change, and then quickly rotating back to portrait - I then tried I the simple Xcode template for a UISplitViewController project.&amp;nbsp; The issue still reproduced, even with only the Apple code.&amp;nbsp; I only found 1 reference to this issue anywhere on the internet (in the Apple forums), confirming my issue, and saying that a bug had been logged with Apple – but no solution.&amp;nbsp; I guess I was able to discover it easily because I would launch our app from my debugger, with the device on the desk, and then pick up my iPad – which caused a couple of quick semi rotations. &lt;/p&gt; &lt;p&gt;&amp;nbsp; &lt;/p&gt; &lt;h4&gt;It’s The Animation &lt;/h4&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;You will notice from the line of code above, that we are telling the button to be added to the toolbar in an animated fashion, in this case a fade-in.&amp;nbsp; In iOS you can manually animate almost anything, but many of the UIKit calls contain flags (as above) so the framework will perform the default animation for you automatically.&amp;nbsp; I was already thinking that the animation was not so good in this case, the button would quickly fade in while the screen finished rotating.&amp;nbsp; If Chuck Norris was using the app he would be ready to click before the button was there!&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;So I tried:&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;[toolbar setItems:items animated:NO];&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;This resulted in almost no visual difference to the user, and…………..no disappearing toolbar button!&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=rr-8AaY3UhA:AjIbylVeYe8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=rr-8AaY3UhA:AjIbylVeYe8:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=rr-8AaY3UhA:AjIbylVeYe8:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?i=rr-8AaY3UhA:AjIbylVeYe8:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=rr-8AaY3UhA:AjIbylVeYe8:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FalafelBlogs/~4/rr-8AaY3UhA" height="1" width="1"/&gt;</description>
      <link>http://feeds.falafel.com/~r/FalafelBlogs/~3/rr-8AaY3UhA/iPad_UISplitViewController_bug_ndash_a_workaround.aspx</link>
      <author>Lance Bullock</author>
      <comments>http://blog.falafel.com/Blogs/10-07-09/iPad_UISplitViewController_bug_ndash_a_workaround.aspx</comments>
      <guid isPermaLink="false">9cc99693-ed2c-4b04-953f-f4d1bbbbb969</guid>
      <pubDate>Fri, 09 Jul 2010 15:59:40 GMT</pubDate>
    <feedburner:origLink>http://blog.falafel.com/Blogs/10-07-09/iPad_UISplitViewController_bug_ndash_a_workaround.aspx</feedburner:origLink></item>
    <item>
      <title>Reusing list items in Android and iOS - a comparison.</title>
      <description>&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"&gt;A very common UI paradigm in mobile development is the scrolling list of items. &amp;nbsp;You have all seen it: flick your finger up and down and the data scrolls by, touch an item and drill down into the details for the touched item. &amp;nbsp;Here are a couple of examples from our Falafel 2 Go app:&lt;br /&gt; &lt;br /&gt; &lt;/p&gt; &lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"&gt;&lt;/p&gt; &lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"&gt;&lt;/p&gt; &lt;h2 style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"&gt;&lt;/h2&gt; &lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"&gt;&lt;/p&gt; &lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"&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;&lt;img alt="" src="http://blog.falafel.com/Images/Android ListView.png" style="width: 140px; height: 279px;" /&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;&lt;img alt="" src="http://blog.falafel.com/Images/ipad TableView.png" style="width: 320px; height: 414px;" /&gt;&lt;br /&gt; &lt;br /&gt; &lt;/p&gt; &lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"&gt;&lt;/p&gt; &lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"&gt;&lt;/p&gt; &lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"&gt;&lt;/p&gt; &lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"&gt;You can probably imagine this is a critical performance area for a resource constrained mobile device: there could be many items in the list, the scrolling must happen in a fast and smooth fashion, and the process should not use excessive CPU or drain the device's battery. &amp;nbsp;Fortunately, both the Android SDK and Apple's iOS provide mechanisms for optimizing the display of your list data, but it is the developers responsibility to use these correctly. &amp;nbsp;This article is not meant to be a comprehensive tutorial on using Android's ListView or iOS's UITableViewController, instead we are going to look at some of the details of list item reuse in the different frameworks.&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;/p&gt; &lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"&gt;&lt;/p&gt; &lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"&gt;&lt;/p&gt; &lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"&gt;&lt;/p&gt; &lt;h4 style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"&gt;Android's ListView and ListAdapter view reuse&lt;/h4&gt; &lt;div&gt;&lt;br /&gt; &lt;/div&gt; &lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"&gt;&lt;/p&gt; &lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"&gt;In the Android architecture, the scrolling list UI object (the "controller" if you will) is called a ListView and the "model" is called a ListAdapter. &amp;nbsp;A ListAdapter subclass is responsible for supplying the data to a ListView for display. &amp;nbsp;The simplest subclass of a ListAdapter is an ArrayAdapter (provided by the Android SDK). &amp;nbsp;If you are just looking for a list of simple strings, then it is enough to use an instance of ArrayAdapter and give it an array of your String object, and you are done. &amp;nbsp;In most cases however, you will want to present additional information within the cell in a more complicated view than just a simple text string. &amp;nbsp;When this is the case, in Android, you will need to subclass one of the ListAdapter classes and override the getView method in order to provide the ListView with a view representation for the list item, this is where the list item reuse is going to come into play.&lt;/p&gt; &lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"&gt;In the Java code below we are subclassing the ArrayAdapter class and overriding the getView method to return a view for the list item that contains an ImageView and 2 TextViews, note that our array adapter is also now holding more than just a simple String object, but an object which represents various items we would like to populate in our list.&lt;br /&gt; &lt;span style="font-family: times;"&gt;&lt;br /&gt; &lt;/span&gt;&lt;/p&gt; &lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;"&gt;&lt;span style="font-family: times;"&gt; &lt;/span&gt;&lt;/p&gt; &lt;div class="reCodeBlock" style="border: 1px  solid  #7f9db9;overflow-y: auto;"&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;01.&lt;/code&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000000;"&gt;public class BlogAdapter extends ArrayAdapter&amp;lt;BlogListData&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;02.&lt;/code&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000000;"&gt;{&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;03.&lt;/code&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;04.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000000;"&gt;BlogListData[] items;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;05.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;06.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000000;"&gt;public BlogAdapter(Context context, int resource, int textViewResourceId,&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;07.&lt;/code&gt;&lt;span&gt;&lt;code&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;&lt;/code&gt;&lt;span style="margin-left: 36px !important;"&gt;&lt;code style="color: #000000;"&gt;BlogListData[] objects)&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;08.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000000;"&gt;{&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;09.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;super&lt;/code&gt;&lt;code style="color: #000000;"&gt;(context, resource, textViewResourceId, objects);&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;10.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;this&lt;/code&gt;&lt;code style="color: #000000;"&gt;.items = objects;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;11.&lt;/code&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;12.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000000;"&gt;}&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;13.&lt;/code&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;14.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000000;"&gt;@Override&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;15.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000000;"&gt;public View getView(int position, View convertView, ViewGroup parent)&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;16.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000000;"&gt;{&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;17.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000000;"&gt;View currentRowView = convertView;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;18.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;if&lt;/code&gt; &lt;code style="color: #000000;"&gt;(currentRowView == &lt;/code&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;null&lt;/code&gt;&lt;code style="color: #000000;"&gt;)&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;19.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000000;"&gt;{&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;20.&lt;/code&gt;&lt;span&gt;&lt;code&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;&lt;/code&gt;&lt;span style="margin-left: 36px !important;"&gt;&lt;code style="color: #000000;"&gt;LayoutInflater li = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;21.&lt;/code&gt;&lt;span&gt;&lt;code&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;&lt;/code&gt;&lt;span style="margin-left: 36px !important;"&gt;&lt;code style="color: #000000;"&gt;currentRowView = li.inflate(R.layout.blogentry, &lt;/code&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;null&lt;/code&gt;&lt;code style="color: #000000;"&gt;);&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;22.&lt;/code&gt;&lt;span&gt;&lt;code&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 60px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;23.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000000;"&gt;}&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;24.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000000;"&gt;ImageView ivBlogger = (ImageView)currentRowView.findViewById(R.id.tvBloggerPic);&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;25.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000000;"&gt;TextView tvBlogTitle = (TextView)currentRowView.findViewById(R.id.tvBlogTitle);&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;26.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000000;"&gt;TextView tvBlogSubtitle = (TextView)currentRowView.findViewById(R.id.tvBlogSubtitle);&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;27.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;28.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #008200;"&gt;// Setup cell data that changes based on row&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;29.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000000;"&gt;ivBlogger.setImageResource(items[position].bloggerDrawable);&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;30.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000000;"&gt;tvBlogSubtitle.setText(items[position].author + &lt;/code&gt;&lt;code style="color: blue;"&gt;" on "&lt;/code&gt; &lt;code style="color: #000000;"&gt;+ items[position].date);&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;31.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000000;"&gt;tvBlogTitle.setText(items[position].title);&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;32.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;return&lt;/code&gt; &lt;code style="color: #000000;"&gt;currentRowView;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;33.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000000;"&gt;}&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;34.&lt;/code&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;35.&lt;/code&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000000;"&gt;}&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;&lt;span style="font-family: times;"&gt;&lt;span style="font-family: times;"&gt;&lt;br /&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;The key piece of logic in the above code is at Line 18. &amp;nbsp;When the ListView calls the getView method of your Adapter, it will pass a previously used view in the convertView parameter, if there is one available. &amp;nbsp;You should check for this and reuse this view if possible, resetting the data for the row to be displayed. &amp;nbsp;If there is no reusable view available then you go ahead and instantiate (inflate) the new object from the XML layout. &amp;nbsp;We then continue on and set the image and text to be shown in our list item in the same manner - whether or not it is new or reused. &amp;nbsp;&lt;br /&gt; &lt;br /&gt;
Another important point is that&amp;nbsp;If you have conditional logic which is setting the values of your views, it is important that it is complete. &amp;nbsp;Consider the following logic:&lt;/p&gt; &lt;p&gt;if &amp;nbsp;(someValue &amp;gt; 5) &amp;nbsp; backgroundColor = RED;&lt;/p&gt; &lt;p&gt;This would typically be perfectly fine if you were always creating new views for the list items, however when reusing views the backgroundColor &amp;nbsp;may have been previously been set to RED and you need to set it back to the default in the else condition. &amp;nbsp;I have seen many "bugs" discussed on the various forums due to this issue.&lt;br /&gt; &lt;br /&gt;
The ListView/ListAdapter architecture also allows for different layouts for different items in the list. &amp;nbsp;In order to have this work with cell reuse, the ListView needs to know which rows are using which type of views, so that it can cache reuse pools separately. &amp;nbsp;We will not go into detail here, but this is accomplished by overriding the getItemViewType and getViewTypeCount in your ListAdapter subclass.&lt;br /&gt; &lt;br /&gt;
Note: &amp;nbsp;Lines 27-29 can also be optimized. &amp;nbsp;You will notice that each time we render a list item we are traversing the layout hierarchy of the view in order to find the view objects we are interested in setting. &amp;nbsp;A solution to this is to place a "holder" object in the tag property of the main view which references the views we are looking for.&lt;br /&gt; &lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;br /&gt; &lt;br /&gt; &lt;/span&gt; &lt;/span&gt;&lt;/p&gt; &lt;h4&gt;iOS UITableViewController, UITableView and UITableViewCell reuse&lt;/h4&gt; &lt;br /&gt; &lt;strong&gt;&lt;br /&gt; &lt;br /&gt; &lt;/strong&gt;Now we will move to iOS (iPhone, iPad) and take a look at reusing list items, which we will call table cells. &amp;nbsp;Aside from the obvious difference that we are now coding in Objective-C instead of Java, there are a couple of other differences, but also some similarity - and the concept is exactly the same. &amp;nbsp;First off, like Android, we will need to implement a method that the UITableView will call when it needs to populate its' rows. &amp;nbsp;In order to do this however, we will not need to subclass this time. &amp;nbsp;The Cocoa Touch framework in iOS commonly uses a delegation pattern, where some other object is specified to perform operations on behalf of another, which makes subclassing unnecessary. &amp;nbsp;In this case, the UITableView will delegate row population to some other object which has been assigned to the UITableView's dataSource property. &amp;nbsp;Typically that will be the UITableViewController, in fact when creating a UITableViewController class, XCode will generate template code for cell reuse.
&lt;p&gt;&lt;br /&gt; &lt;/p&gt; &lt;p&gt; &lt;br /&gt;
The UITableView will call the tableView:cellForRowAtIndexPath: method of its' dataSource for each row it wishes to populate in the list. &amp;nbsp;Our implementation of this looks as follows:&lt;/p&gt; &lt;p&gt;&lt;br /&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;div class="reCodeBlock" style="border: 1px  solid  #7f9db9;overflow-y: auto;"&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;01.&lt;/code&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000000;"&gt;- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;02.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;03.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;static&lt;/code&gt; &lt;code style="color: #000000;"&gt;NSString *CellIdentifier = @&lt;/code&gt;&lt;code style="color: blue;"&gt;"Cell"&lt;/code&gt;&lt;code style="color: #000000;"&gt;;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;04.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;05.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000000;"&gt;UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;06.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;if&lt;/code&gt; &lt;code style="color: #000000;"&gt;(cell == nil) &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;07.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000000;"&gt;{&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;08.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000000;"&gt;cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;09.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;10.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #008200;"&gt;// Setup cell for new cell instances&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;11.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000000;"&gt;cell.contentView.backgroundColor = [UIColor clearColor];&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;12.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000000;"&gt;cell.backgroundColor = [UIColor clearColor];&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;13.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;14.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000000;"&gt;cell.textLabel.textColor= [UIColor whiteColor];&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;15.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000000;"&gt;cell.textLabel.font = [cell.textLabel.font fontWithSize:14];&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;16.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&lt;code style="color: #000000;"&gt;cell.textLabel.numberOfLines=2;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;17.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 24px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;18.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000000;"&gt;}&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;19.&lt;/code&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;20.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #008200;"&gt;// Setup cell data that changes based on row&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;21.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000000;"&gt;cell.imageView.image = [bloggerImageLookup imageForBlogger:((FeedInfo*)[feedItems objectAtIndex:indexPath.row]).author];&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;22.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000000;"&gt;cell.textLabel.text = ((FeedInfo*)[feedItems objectAtIndex:indexPath.row]).title;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;23.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #000000;"&gt;cell.detailTextLabel.text= ((FeedInfo*)[feedItems objectAtIndex:indexPath.row]).author;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;24.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #ffffff;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;25.&lt;/code&gt;&lt;span&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;span style="margin-left: 12px !important;"&gt;&lt;code style="color: #006699; font-weight: bold;"&gt;return&lt;/code&gt; &lt;code style="color: #000000;"&gt;cell;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="background-color: #f8f8f8;"&gt;&lt;code style="color: #5c5c5c; float: left; width: 3em; padding-right: 0.3em; text-align: right; display: block;"&gt;26.&lt;/code&gt;&lt;span&gt;&lt;span style="margin-left: 0px !important;"&gt;&lt;code style="color: #000000;"&gt;}&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;p&gt;&lt;br /&gt; &lt;/p&gt; &lt;p&gt;The key code here occurs in lines 5 and 6. &amp;nbsp;In line 5 you see us using the selector dequeueReusableCellWithIdentifier:, to invoke this method of the UITableView which will return us a reusable UITableViewCell if one is available, very similar to the Android model, except in this case we need to make a call instead of being directly passed a reusable cell. &amp;nbsp;After that, the pattern is the same, we only allocate and init a new UITableViewCell if necessary, and then we reset or set properties to set up our table cell - once again it is important to ensure your logic is complete when reusing cells.&lt;br /&gt; &lt;br /&gt;
As with Android, you may have different UITableViewCells for each row of data. &amp;nbsp;In this case, &amp;nbsp;implementing additional methods is not necessary, you simply supply a NSString as a "CellIdentifier" both when create the new cell, and you retrieve the cell from the queue, that code is also seen above. &amp;nbsp;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;/p&gt; &lt;h4&gt;Wrap-Up&lt;/h4&gt; &lt;p&gt;&lt;br /&gt; &lt;/p&gt; &lt;p&gt;The key point I would like to make here is that while both mobile platforms provide simple and nice mechanisms for efficiently reusing list items, it is not automatic in either case. &amp;nbsp;There is nothing that enforces the reuse of these objects, and you can tell from examining the above code that it is entirely possible to allocate/create brand new views or cells for each item that needs to be displayed - in which case your user is likely a few "flicks" away from being saddled with a very ill-behaving mobile device.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=Z-owoqjlaPI:HTzK154az-A:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=Z-owoqjlaPI:HTzK154az-A:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=Z-owoqjlaPI:HTzK154az-A:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?i=Z-owoqjlaPI:HTzK154az-A:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.falafel.com/~ff/FalafelBlogs?a=Z-owoqjlaPI:HTzK154az-A:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FalafelBlogs?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FalafelBlogs/~4/Z-owoqjlaPI" height="1" width="1"/&gt;</description>
      <link>http://feeds.falafel.com/~r/FalafelBlogs/~3/Z-owoqjlaPI/Reusing_list_items_in_Android_and_iOS_-_a_comparison.aspx</link>
      <author>Lance Bullock</author>
      <comments>http://blog.falafel.com/Blogs/10-07-08/Reusing_list_items_in_Android_and_iOS_-_a_comparison.aspx</comments>
      <guid isPermaLink="false">73a9d6c3-9f29-44f1-a3d7-e4eb9b8ddbac</guid>
      <pubDate>Thu, 08 Jul 2010 18:40:00 GMT</pubDate>
    <feedburner:origLink>http://blog.falafel.com/Blogs/10-07-08/Reusing_list_items_in_Android_and_iOS_-_a_comparison.aspx</feedburner:origLink></item>
  </channel>
</rss>
