<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Akash Kava &#187; Microsoft</title>
	<atom:link href="http://akashkava.com/blog/tag/microsoft/feed/" rel="self" type="application/rss+xml" />
	<link>http://akashkava.com/blog</link>
	<description>Founder of NeuroSpeech</description>
	<lastBuildDate>Tue, 10 Apr 2012 18:00:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>MEF vs. Unity in composite application (Prism)</title>
		<link>http://akashkava.com/blog/391/mef-vs-unity-in-composite-application-prism/</link>
		<comments>http://akashkava.com/blog/391/mef-vs-unity-in-composite-application-prism/#comments</comments>
		<pubDate>Wed, 27 Apr 2011 07:40:00 +0000</pubDate>
		<dc:creator>Akash Kava</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[MEF]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Prism]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Unity]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://akashkava.com/blog/?p=391</guid>
		<description><![CDATA[This article describes differences between MEF and Unity which may help you in deciding which technology you must use while making composite application. Both technologies are useful and easy to understand, and offer a rich set of features that can make integration of various software components very easy. However, both being little different in functioning [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://akashkava.com/blog/391/mef-vs-unity-in-composite-application-prism/";
		digg_bgcolor = "";
		digg_skin = "";
		digg_window = "";
		digg_title = "MEF+vs.+Unity+in+composite+application+%28Prism%29";
		digg_media = "";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fakashkava.com%2Fblog%2F391%2Fmef-vs-unity-in-composite-application-prism%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fakashkava.com%2Fblog%2F391%2Fmef-vs-unity-in-composite-application-prism%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>This article describes differences between MEF and Unity which may help you in deciding which technology you must use while making composite application.
</p>
<p>Both technologies are useful and easy to understand, and offer a rich set of features that can make integration of various software components very easy. However, both being little different in functioning they offer exact same level of features but choosing wrong one can lead to chaos.
</p>
<p>So we will drill down to differences between their operations.
</p>
<div>
<table style="border-collapse:collapse" border="0">
<colgroup>
<col style="width:284px"/>
<col style="width:344px"/></colgroup>
<tbody valign="top">
<tr style="background: #d9d9d9">
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  solid #d9d9d9 0.5pt; border-left:  solid #d9d9d9 0.5pt; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>Unity</p>
</td>
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  solid #d9d9d9 0.5pt; border-left:  none; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>MEF</p>
</td>
</tr>
<tr>
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  none; border-left:  solid #d9d9d9 0.5pt; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>Unity creates new instance of type by default.</p>
</td>
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  none; border-left:  none; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>MEF creates singleton instance of type by default.</p>
</td>
</tr>
<tr>
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  none; border-left:  solid #d9d9d9 0.5pt; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>Unity does not require registration for classes. This means you can instantiate any other third party type.</p>
</td>
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  none; border-left:  none; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>MEF requires Export attribute to be specified on the class. MEF cannot create instance of third party type unless it defines Export.</p>
</td>
</tr>
<tr>
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  none; border-left:  solid #d9d9d9 0.5pt; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>Unity requires type registration in code for interface types.</p>
</td>
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  none; border-left:  none; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>No registration, simple Export attribute does it all.</p>
</td>
</tr>
<tr>
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  none; border-left:  solid #d9d9d9 0.5pt; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>Unity container can compose IUnityContainer property in the composed class where you can further access it easily in your own scope. This behavior is not useful for Plugin architecture as getting access to IUnityContainer may result in full access to your application.</p>
</td>
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  none; border-left:  none; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>MEF does not allow composition of CompositionContainer, which blocks access to MEF in your own scope if you do not have CompositionContainer. This is useful in Plugin architecture where third party code has limited access to your application. </p>
</td>
</tr>
<tr>
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  none; border-left:  solid #d9d9d9 0.5pt; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>Unity offers injection method mechanism, that can define IUnityContainer parameter and get the unity container object, with which you can compose other private properties manually.</p>
</td>
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  none; border-left:  none; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>MEF can only compose public properties, this is dangerous as anyone can change public property and make application crash easily.</p>
</td>
</tr>
<tr>
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  none; border-left:  solid #d9d9d9 0.5pt; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>Inside your application&#8217;s framework code, Unity serves the best as it gives you full control over type hierarchy, lifecycle and allows you to utilize third party components easily without writing much of code. </p>
</td>
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  none; border-left:  none; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>Inside your application, MEF will put lots of restrictions in which your framework can operate as it cannot easily compose third party components and it will force you to write numerous attributes in your code without which it will fail drastically.</p>
</td>
</tr>
<tr>
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  none; border-left:  solid #d9d9d9 0.5pt; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>Mostly, User Interface objects like your View, or UserControl or any UIElement can never be shared as no UIElement can have two parents at same time. So default behavior of Unity to create a new instance of type is very helpful.</p>
</td>
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  none; border-left:  none; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>Default behavior of MEF will create only one single instance of UI object, that will lead to trouble, not only that, if UI object is third party tool, MEF will not compose it. You can create multiple copies of exported type by specifying one more attribute called [PartCreationPolicy(Shared)], however it is very time comsuming and tedious to define this one every UI related type we create.</p>
</td>
</tr>
<tr>
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  none; border-left:  solid #d9d9d9 0.5pt; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>Unity does allow singleton objects, but for that you have to register an instance to the container.</p>
</td>
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  none; border-left:  none; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>MEF by default creates singleton object only.</p>
</td>
</tr>
<tr>
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  none; border-left:  solid #d9d9d9 0.5pt; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>Unity does not allow multiple registrations for same instance in same scope sharing same interface but different type. </p>
</td>
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  none; border-left:  none; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>MEF allows multiple singleton objects of different type sharing same interface.</p>
</td>
</tr>
<tr>
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  none; border-left:  solid #d9d9d9 0.5pt; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>Unity works best for MVVM, as composing user interface parts can be very easy with unity.</p>
</td>
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  none; border-left:  none; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>MEF does not work great with MVVM as it will create singleton objects that will behave strangely in runtime and lead to UI failure.</p>
</td>
</tr>
<tr>
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  none; border-left:  solid #d9d9d9 0.5pt; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>Unity is not good for Modularity, as composing IUnityContainer will offer more control of unity lifecycle to third party modules.</p>
</td>
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  none; border-left:  none; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>MEF is good for Modularity, as it will not allow modification of composition thus offering great deal of security between modules.</p>
</td>
</tr>
<tr>
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  none; border-left:  solid #d9d9d9 0.5pt; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>So, to develop a framework, MVVM Crud application and a UI framework, Unity is the best.</p>
</td>
<td vAlign="middle" style="padding-top: 2px; padding-left: 2px; padding-bottom: 2px; padding-right: 2px; border-top:  none; border-left:  none; border-bottom:  solid #d9d9d9 0.5pt; border-right:  solid #d9d9d9 0.5pt">
<p>To expose some functionality of your application for third party modules to register and access limited functionality, MEF is the best.</p>
</td>
</tr>
</tbody>
</table>
</div>
<p> <br />
 </p>
<p>Following is outline of how your application should be,
</p>
<p>Unity Container must compose and manage your application&#8217;s framework, UI and MEF modules.
</p>
<p>MEF will only expose limited functionality from Unity Container to third party modules.
</p>
<p>No module, through MEF should have access to unity container at all.
</p>
<p><img src="http://akashkava.com/blog/wp-content/uploads/2011/04/042711_0740_MEFvsUnityi12.png" alt=""/>
	</p>
<p>Thank you for reading this article, please put your suggestions below in the comment. I do not intend to make any specific rules and regulations here but I am suggesting the architecture based on the differences I have outlined.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fakashkava.com%2Fblog%2F391%2Fmef-vs-unity-in-composite-application-prism%2F&amp;title=MEF%20vs.%20Unity%20in%20composite%20application%20%28Prism%29"><img src="http://akashkava.com/blog/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://akashkava.com/blog/391/mef-vs-unity-in-composite-application-prism/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>UI Atoms 1.7.5 Released</title>
		<link>http://akashkava.com/blog/387/ui-atoms-1-7-5-released/</link>
		<comments>http://akashkava.com/blog/387/ui-atoms-1-7-5-released/#comments</comments>
		<pubDate>Sun, 03 Apr 2011 09:04:00 +0000</pubDate>
		<dc:creator>Akash Kava</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[RIA]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Customize]]></category>
		<category><![CDATA[DataForm]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[UI Atoms]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://akashkava.com/blog/387/ui-atoms-1-7-5-released/</guid>
		<description><![CDATA[We are happy to announce new release of UI Atoms 1.7.5 with following new features. New AtomDataForm Control Tabs in AtomForm and AtomDataForm Lambda Binding Extensions Introducing new Control AtomDataForm AtomForm did support UI Validations, however Microsoft RIA Services Client has some inbuilt validation and support for IEditableObject. So we created a new AtomDataForm that [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://akashkava.com/blog/387/ui-atoms-1-7-5-released/";
		digg_bgcolor = "";
		digg_skin = "";
		digg_window = "";
		digg_title = "UI+Atoms+1.7.5+Released";
		digg_media = "";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fakashkava.com%2Fblog%2F387%2Fui-atoms-1-7-5-released%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fakashkava.com%2Fblog%2F387%2Fui-atoms-1-7-5-released%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>We are happy to announce new release of UI Atoms 1.7.5 with following new features.</p>
<ol>
<li>New AtomDataForm Control </li>
<li>Tabs in AtomForm and AtomDataForm </li>
<li>Lambda Binding Extensions </li>
</ol>
<h2>Introducing new Control AtomDataForm</h2>
<p>AtomForm did support UI Validations, however Microsoft RIA Services Client has some inbuilt validation and support for IEditableObject. So we created a new AtomDataForm that supports RIA Services validation and IEditableObject support.</p>
<ol>
<li>AtomDataForm supports object with IEditableObject interface and fires event for BeginEdit, CancelEdit and EndEdit </li>
<li>AtomDataForm displays items in read only mode unless Edit button is clicked </li>
<li>After edit button is clicked, Save and Cancel button appear for you to persist changes or cancel changes </li>
<li>AtomDataForm contains UI Element (TextBox, ComboBox etc) as children, so you can easily define child ui element in your xaml as shown in sample below </li>
<li>AtomDataForm supports Tabbed layout, for that you can insert your items within AtomDataFormTab as shown in example below </li>
<li>Following sample illustrates Tabs, but you can also create simple user interface without tab as well </li>
<li>You can also use AtomDataFormGroup to group items in to a headered group </li>
<li>Every child element of AtomDataForm can be accessed in code behind file easily because they appear as a variables when you define x:Name property </li>
<li>AtomDataForm supports CanChangeDataContext property, which is false when the form is in edit mode </li>
<li>You can easily reuse any third party control within AtomDataForm, AtomDataFormGroup and AtomDataFormTab </li>
</ol>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4af705bb-bc40-4470-8c60-7e87ee7745ca" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">AtomDataForm Sample</div>
<div style="background: #ddd; max-height: 500px; overflow: auto">
<ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px; white-space: nowrap">
<li><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomDataForm</span> </li>
<li>   <span style="color:#ff0000"> Grid.Column</span><span style="color:#0000ff">=&quot;1&quot;</span> </li>
<li>   <span style="color:#ff0000"> DataContext</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> SelectedItem</span><span style="color:#0000ff">,</span><span style="color:#ff0000">ElementName</span><span style="color:#0000ff">=dataGrid}&quot; &gt;</span></li>
<li>            <span style="color:#a31515"></span></li>
<li>    <span style="color:#a31515"></span><span style="color:#008000">&lt;!&#8211; 1st Tab&#8211;&gt;</span></li>
<li>    <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomDataFormTab</span><span style="color:#ff0000"> Header</span><span style="color:#0000ff">=&quot;Default&quot;&gt;</span></li>
<li>                <span style="color:#a31515"></span></li>
<li>        <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span> </li>
<li>           <span style="color:#ff0000"> ns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">AtomDataForm.Label</span><span style="color:#0000ff">=&quot;Name:&quot;</span> </li>
<li>           <span style="color:#ff0000"> Text</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> ProductName</span><span style="color:#0000ff">,</span><span style="color:#ff0000"> Mode</span><span style="color:#0000ff">=TwoWay}&quot;/&gt;</span></li>
<li>                <span style="color:#a31515"></span></li>
<li>        <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomToggleButtonBar</span> </li>
<li>           <span style="color:#ff0000"> ns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">AtomDataForm.Label</span><span style="color:#0000ff">=&quot;Type:&quot;</span></li>
<li>           <span style="color:#ff0000"> SelectedItem</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> ProductType</span><span style="color:#0000ff">,</span><span style="color:#ff0000">Mode</span><span style="color:#0000ff">=TwoWay}&quot;&gt;</span></li>
<li>            <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">sys</span><span style="color:#0000ff">:</span><span style="color:#a31515">String</span><span style="color:#0000ff">&gt;</span><span style="color:#a31515">Product</span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">sys</span><span style="color:#0000ff">:</span><span style="color:#a31515">String</span><span style="color:#0000ff">&gt;</span></li>
<li>            <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">sys</span><span style="color:#0000ff">:</span><span style="color:#a31515">String</span><span style="color:#0000ff">&gt;</span><span style="color:#a31515">Service</span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">sys</span><span style="color:#0000ff">:</span><span style="color:#a31515">String</span><span style="color:#0000ff">&gt;</span></li>
<li>        <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomToggleButtonBar</span><span style="color:#0000ff">&gt;</span></li>
<li>                <span style="color:#a31515"></span></li>
<li>        <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span></li>
<li>           <span style="color:#ff0000"> ns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">AtomDataForm.Label</span><span style="color:#0000ff">=&quot;Folder:&quot;&gt;</span></li>
<li>            <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomDataForm.CommandBox</span><span style="color:#0000ff">&gt;</span></li>
<li>                <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;&#8230;&quot;/&gt;</span></li>
<li>            <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomDataForm.CommandBox</span><span style="color:#0000ff">&gt;</span></li>
<li>        <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">TextBox</span><span style="color:#0000ff">&gt;</span></li>
<li>                <span style="color:#a31515"></span></li>
<li>    <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomDataFormTab</span><span style="color:#0000ff">&gt;</span></li>
<li>            <span style="color:#a31515"></span></li>
<li>    <span style="color:#a31515"></span><span style="color:#008000">&lt;!&#8211; 2nd Tab&#8211;&gt;</span></li>
<li>    <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomDataFormTab</span><span style="color:#ff0000"> Header</span><span style="color:#0000ff">=&quot;General&quot;&gt;</span></li>
<li>                <span style="color:#a31515"></span></li>
<li>        <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span> </li>
<li>           <span style="color:#ff0000"> ns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">AtomDataForm.Label</span><span style="color:#0000ff">=&quot;Email:&quot;</span>  </li>
<li>           <span style="color:#ff0000"> Text</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> Email</span><span style="color:#0000ff">,</span><span style="color:#ff0000"> Mode</span><span style="color:#0000ff">=TwoWay}&quot;/&gt;</span></li>
<li>                <span style="color:#a31515"></span></li>
<li>    <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomDataFormTab</span><span style="color:#0000ff">&gt;</span></li>
<li>            <span style="color:#a31515"></span></li>
<li>    <span style="color:#a31515"></span><span style="color:#008000">&lt;!&#8211; 3rd Conditional Tab&#8211;&gt;</span></li>
<li>    <span style="color:#a31515"></span><span style="color:#008000">&lt;!&#8211; This tab will be visible only if Product&#39;s </span></li>
<li>    <span style="color:#008000">IsTypeService is true&#8211;&gt;</span></li>
<li>    <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomDataFormTab</span> </li>
<li>       <span style="color:#ff0000"> Header</span><span style="color:#0000ff">=&quot;Service&quot;</span> </li>
<li>       <span style="color:#ff0000"> IsEnabled</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> IsTypeService}</span><span style="color:#0000ff">&quot;&gt;</span></li>
<li>                <span style="color:#a31515"></span></li>
<li>        <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span> </li>
<li>           <span style="color:#ff0000"> ns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">AtomDataForm.Label</span><span style="color:#0000ff">=&quot;Service Details:&quot;/&gt;</span></li>
<li>                <span style="color:#a31515"></span></li>
<li>    <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomDataFormTab</span><span style="color:#0000ff">&gt;</span></li>
<li>&nbsp;</li>
<li>    <span style="color:#a31515"></span><span style="color:#008000">&lt;!&#8211; 4th Conditional Tab&#8211;&gt;</span></li>
<li>    <span style="color:#a31515"></span><span style="color:#008000">&lt;!&#8211; This tab will be visible only if Product&#39;s </span></li>
<li>    <span style="color:#008000">IsTypeProduct is true&#8211;&gt;</span></li>
<li>    <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomDataFormTab</span> </li>
<li>       <span style="color:#ff0000"> Header</span><span style="color:#0000ff">=&quot;Product&quot;</span> </li>
<li>       <span style="color:#ff0000"> IsEnabled</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> IsTypeProduct}</span><span style="color:#0000ff">&quot;&gt;</span></li>
<li>                <span style="color:#a31515"></span></li>
<li>        <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> ns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">AtomDataForm.Label</span><span style="color:#0000ff">=&quot;Product Details:&quot;</span> <span style="color:#0000ff"> &gt;</span></li>
<li>            <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomDataForm.CommandBox</span><span style="color:#0000ff">&gt;</span></li>
<li>                <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Search&quot;/&gt;</span></li>
<li>            <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomDataForm.CommandBox</span><span style="color:#0000ff">&gt;</span></li>
<li>        <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">TextBox</span><span style="color:#0000ff">&gt;</span></li>
<li>                <span style="color:#a31515"></span></li>
<li>    <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomDataFormTab</span><span style="color:#0000ff">&gt;</span></li>
<li>            <span style="color:#a31515"></span></li>
<li><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomDataForm</span><span style="color:#0000ff">&gt;</span></li>
</ol></div>
</p></div>
</p></div>
<p>In above sample you can notice following things,</p>
<ol>
<li>Header property of AtomDataFormTab is displayed in the title section on the top </li>
<li>AtomDataFormTab contains children and each child can have properties as below
<ol>
<li>ns:AtomDataForm.Label displays label on left side </li>
<li>ns:AtomDataForm.Description displays description on bottom </li>
<li>ns:AtomDataForm.Title displays title on the top of control </li>
<li>ns:AtomDataForm.CommandBox displays a UI Element on the right corner, usually a search button or expand button </li>
</ol>
</li>
<li>AtomDataFormTab supports IsEnabled binding, you can bind this property to show/hide the tab as shown in the example above </li>
<li>Every child elemen of either AtomDataForm , AtomDataFormTab or AtomDataFormGroup supports Visibility and IsEnabled binding
<ol>
<li>If Visibility is bound and it results in Collapsed then entire form item is not displayed </li>
<li>IsEnabled binding can enable/disable the editable control </li>
</ol>
</li>
</ol>
<p>Following is screenshot of Tabbed AtomDataForm in edit mode</p>
<p><a href="http://akashkava.com/blog/wp-content/uploads/2011/04/AtomDataForm.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="AtomDataForm" border="0" alt="AtomDataForm" src="http://akashkava.com/blog/wp-content/uploads/2011/04/AtomDataForm_thumb.png" width="367" height="275" /></a></p>
<h2>Introducing Lambda Binder Extensions</h2>
<p>Writing binding expressions with conditions and converters can be very complex especially rewriting many and same logic at different classes. Now UI Atoms support, Lambda Binding Extensions which lets you do binding within the code without creating any complex IValueConverter implementation.</p>
<h3>Bind Method Extension</h3>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e332ae3d-d3f7-4a80-9c53-c235f4c6914e" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">Element Property Binding</div>
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;">
<li>theForm.Bind(<span style="color:#2b91af">AtomDataForm</span>.HeaderProperty,</li>
<li>    () =&gt; <span style="color:#0000ff">string</span>.Format(<span style="color:#a31515">&quot;{0} ({1})&quot;</span>,</li>
<li>            productName.Text,</li>
<li>            typeToggleButtonBar.SelectedItem</li>
<li>        ));</li>
</ol></div>
</p></div>
</p></div>
<p>This will bind theForm’s Header property to an expression that will combine properties of two different elements. And this will also automatically update when any of bound source or its property will change.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3002cb7e-bef1-4f9b-9df1-b62ba184b9b3" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">DataContext Property Binding</div>
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;">
<li>theForm.Bind(<span style="color:#2b91af">AtomDataForm</span>.HeaderProperty, </li>
<li>    () =&gt; <span style="color:#0000ff">string</span>.Format(<span style="color:#a31515">&quot;{0} ({1})&quot;</span>,</li>
<li>            theForm.DataContext.Property(<span style="color:#a31515">&quot;ProductName&quot;</span>),</li>
<li>            theForm.DataContext.Property(<span style="color:#a31515">&quot;ProductType&quot;</span>)</li>
<li>        ));</li>
</ol></div>
</p></div>
</p></div>
<p>Assuming, we may not have property information at design time, but we know that DataContext will be set to an object containing properties, then we can write Property extension method as shown above.</p>
<h3>BindVisibility Method Extension</h3>
<p>Visibility converters are very frequent so we created a BindVisibility extension method that will let you specify a boolean expression that will be converted to Visibility on the fly.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a064c496-433a-43e7-a96f-5b55bd5a8449" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">BindVisibility Extension</div>
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;">
<li>productTab.BindVisibility(</li>
<li>    () =&gt; </li>
<li>        typeToggleButtonBar.SelectedIndex == 0);</li>
</ol></div>
</p></div>
</p></div>
<p>These extensions can be used anywhere in any third party controls as well.</p>
<h3>Download Now</h3>
<p><a href="http://uiatoms.neurospeech.com/v1/download/UIAtoms2010Demo.zip" target="_blank">Click here</a> to download your free demo copy of NeuroSpeech UI Atoms 1.7.5</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fakashkava.com%2Fblog%2F387%2Fui-atoms-1-7-5-released%2F&amp;title=UI%20Atoms%201.7.5%20Released"><img src="http://akashkava.com/blog/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://akashkava.com/blog/387/ui-atoms-1-7-5-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lambda Binder for WPF and Silverlight</title>
		<link>http://akashkava.com/blog/382/lamda-binder-for-wpf-and-silverlight/</link>
		<comments>http://akashkava.com/blog/382/lamda-binder-for-wpf-and-silverlight/#comments</comments>
		<pubDate>Sun, 20 Mar 2011 10:19:00 +0000</pubDate>
		<dc:creator>Akash Kava</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Binding]]></category>
		<category><![CDATA[Expression]]></category>
		<category><![CDATA[Lambda]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[MultiBinding]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[UI Atoms]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://akashkava.com/blog/382/lamda-binder-for-wpf-and-silverlight/</guid>
		<description><![CDATA[LambdaBinder class helps in creating complex binding expressions without having to create IValueConverter and IMultiValueConverter, it lets you write inline expresions with advanced binding scenarios. Lets say, you have two TextBox for first and last name and you want a Title to be displayed as addition of both. So lets say, you can write it [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://akashkava.com/blog/382/lamda-binder-for-wpf-and-silverlight/";
		digg_bgcolor = "";
		digg_skin = "";
		digg_window = "";
		digg_title = "Lambda+Binder+for+WPF+and+Silverlight";
		digg_media = "";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fakashkava.com%2Fblog%2F382%2Flamda-binder-for-wpf-and-silverlight%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fakashkava.com%2Fblog%2F382%2Flamda-binder-for-wpf-and-silverlight%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>LambdaBinder class helps in creating complex binding expressions without having to create IValueConverter and IMultiValueConverter, it lets you write inline expresions with advanced binding scenarios.</p>
<p>Lets say, you have two TextBox for first and last name and you want a Title to be displayed as addition of both.</p>
<p>So lets say, you can write it as follow,</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9061959b-fde6-475a-bf14-95c7053acc05" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">Adding Two Properties</div>
<div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px;">title.Bind(<span style="color:#2b91af">TextBlock</span>.TextProperty, <br />     () =&gt; firstName.Text + <span style="color:#a31515">&quot; &quot;</span> + lastName.Text);</div>
</p></div>
</p></div>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:be7019f9-9dce-4972-870e-e80107dfd84c" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">Formatting Properties</div>
<div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px;">title.Bind(<span style="color:#2b91af">TextBlock</span>.TextProperty, <br />     () =&gt; <span style="color:#0000ff">string</span>.Format(<span style="color:#a31515">&quot;{0} {1}&quot;</span>, <br />         firstName.Text, lastName.Text));</div>
</p></div>
</p></div>
<p>You can pass on the Linq expression to Bind extension method of LamdaBinder and that will convert and set binding so that anytime if firstName or lastName is modified, the title will be updated automatically.</p>
<p>Assuming I want some hypothetical visibility logic, for example, only if the firstName is entered, lastName should be visible.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5714191b-945b-42ad-ab19-bb35ba18d822" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">Conditional Visibility Binding</div>
<div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px;">lastName.Bind(<span style="color:#2b91af">TextBox</span>.VisibilityProperty, <br />     () =&gt; firstName.Text.Length &gt; 0 ? <span style="color:#2b91af">Visibility</span>.Visible : <br />         <span style="color:#2b91af">Visibility</span>.Collapsed);</div>
</p></div>
</p></div>
<p>You can also use this to avoid writing IValueConverters and do inline binding in code very easily.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3581c9f9-18d6-4824-97c5-f4d710e7ecd4" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">Lambda Binder</div>
<div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px;"><span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">LambdaBinder</span><br /> {</p>
<p>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> Bind(<br />         <span style="color:#0000ff">this</span> <span style="color:#2b91af">DependencyObject</span> dest, <br />         <span style="color:#2b91af">DependencyProperty</span> destProperty, <br />         <span style="color:#2b91af">Expression</span>&lt;Func&lt;<span style="color:#0000ff">object</span>&gt;&gt; func)<br />     {<br />         <span style="color:#2b91af">MultiBinding</span> b = <span style="color:#0000ff">new</span> <span style="color:#2b91af">MultiBinding</span>();<br />         b.Converter = <span style="color:#0000ff">new</span> <span style="color:#2b91af">MultiDelegateConverter</span>(func.Compile());<br />         <span style="color:#2b91af">LambdaBindingBuilder</span> bb = <span style="color:#0000ff">new</span> <span style="color:#2b91af">LambdaBindingBuilder</span>(b);<br />         bb.Visit(func.Body);<br />         <span style="color:#2b91af">BindingOperations</span>.SetBinding(dest, destProperty, b);<br />     }</p>
<p> }</p>
<p> <span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">LambdaBindingBuilder</span> : <span style="color:#2b91af">ExpressionVisitor</span><br /> {<br />     <span style="color:#0000ff">private</span> <span style="color:#2b91af">MultiBinding</span> multiBinding;</p>
<p>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">string</span> lastPath = <span style="color:#0000ff">null</span>;</p>
<p>     <span style="color:#0000ff">public</span> LambdaBindingBuilder(<span style="color:#2b91af">MultiBinding</span> mb)<br />     {<br />         <span style="color:#0000ff">this</span>.multiBinding = mb;<br />     }</p>
<p>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">override</span> System.Linq.Expressions.<span style="color:#2b91af">Expression</span> VisitMember(<span style="color:#2b91af">MemberExpression</span> node)<br />     {<br />         <span style="color:#2b91af">PropertyInfo</span> p = node.Member <span style="color:#0000ff">as</span> <span style="color:#2b91af">PropertyInfo</span>;<br />         <span style="color:#0000ff">if</span> (p != <span style="color:#0000ff">null</span>) {<br />             <span style="color:#0000ff">if</span> (<span style="color:#0000ff">string</span>.IsNullOrWhiteSpace(lastPath))<br />             {<br />                 lastPath = p.Name;<br />             }<br />             <span style="color:#0000ff">else</span> {<br />                 lastPath = p.Name + <span style="color:#a31515">&quot;.&quot;</span> + lastPath;<br />             }<br />         }<br />         <span style="color:#2b91af">FieldInfo</span> f = node.Member <span style="color:#0000ff">as</span> <span style="color:#2b91af">FieldInfo</span>;<br />         <span style="color:#0000ff">if</span> (f != <span style="color:#0000ff">null</span>) { <br />             <span style="color:#2b91af">Binding</span> b = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Binding</span>(lastPath);<br />             b.Source = System.Linq.Expressions.<span style="color:#2b91af">Expression</span>.Lambda&lt;Func&lt;<span style="color:#0000ff">object</span>&gt;&gt;(node).Compile()();<br />             multiBinding.Bindings.Add(b);<br />             lastPath = <span style="color:#0000ff">null</span>;<br />         }<br />         <span style="color:#0000ff">return</span> <span style="color:#0000ff">base</span>.VisitMember(node);<br />     }</p>
<p>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">override</span> System.Linq.Expressions.<span style="color:#2b91af">Expression</span> VisitConstant(<span style="color:#2b91af">ConstantExpression</span> node)<br />     {<br />         <span style="color:#0000ff">if</span> (!<span style="color:#0000ff">string</span>.IsNullOrWhiteSpace(lastPath)) {<br />             <span style="color:#2b91af">Binding</span> b = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Binding</span>(lastPath);<br />             b.Source = node.Value;<br />             multiBinding.Bindings.Add(b);<br />             lastPath = <span style="color:#0000ff">null</span>;<br />         }<br />         <span style="color:#0000ff">return</span> <span style="color:#0000ff">base</span>.VisitConstant(node);<br />     }<br /> }</p>
<p> <span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MultiDelegateConverter</span> : <span style="color:#2b91af">IMultiValueConverter</span><br /> {<br />     <span style="color:#0000ff">private</span> Func&lt;<span style="color:#0000ff">object</span>&gt; func;</p>
<p>     <span style="color:#0000ff">public</span> MultiDelegateConverter(Func&lt;<span style="color:#0000ff">object</span>&gt; func)<br />     {<br />         <span style="color:#0000ff">this</span>.func = func;<br />     }</p>
<p>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">object</span> Convert(<span style="color:#0000ff">object</span>[] values, <br />         <span style="color:#2b91af">Type</span> targetType, <br />         <span style="color:#0000ff">object</span> parameter, <br />         System.Globalization.<span style="color:#2b91af">CultureInfo</span> culture)<br />     {<br />         <span style="color:#0000ff">return</span> func();<br />     }</p>
<p>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">object</span>[] ConvertBack(<span style="color:#0000ff">object</span> value, <br />         <span style="color:#2b91af">Type</span>[] targetTypes, <br />         <span style="color:#0000ff">object</span> parameter, <br />         System.Globalization.<span style="color:#2b91af">CultureInfo</span> culture)<br />     {<br />         <span style="color:#0000ff">throw</span> <span style="color:#0000ff">new</span> <span style="color:#2b91af">NotImplementedException</span>();<br />     }<br /> }</div>
</p></div>
</p></div>
<p>&#160;</p>
<p>LambdaBinder is part of UI Atoms suite. At NeuroSpeech, we do research on UI and we are coming up with more interesting featues in UI Atoms.</p>
<p>Please <a href="http://uiatoms.neurospeech.com/silverlight/" target="_blank">Click Here</a> to download latest update of UI Atoms with AtomForm including Tabs in the form.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fakashkava.com%2Fblog%2F382%2Flamda-binder-for-wpf-and-silverlight%2F&amp;title=Lambda%20Binder%20for%20WPF%20and%20Silverlight"><img src="http://akashkava.com/blog/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://akashkava.com/blog/382/lamda-binder-for-wpf-and-silverlight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Detach Entities Recursively and Attach to New DomainContext in Entity Framework and RIA Services</title>
		<link>http://akashkava.com/blog/379/detach-entities-recursively-and-attach-to-new-domaincontext-in-entity-framework-and-ria-services/</link>
		<comments>http://akashkava.com/blog/379/detach-entities-recursively-and-attach-to-new-domaincontext-in-entity-framework-and-ria-services/#comments</comments>
		<pubDate>Sun, 06 Feb 2011 08:03:00 +0000</pubDate>
		<dc:creator>Akash Kava</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[RIA]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[EF]]></category>
		<category><![CDATA[EF4]]></category>
		<category><![CDATA[Entity]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[RIA Services]]></category>
		<category><![CDATA[Services]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://akashkava.com/blog/?p=379</guid>
		<description><![CDATA[Entity Framework and RIA Services do not allow Entities to be added/removed from cross containers. In order to move Entity from one DomainContext/ObjectContext to another DomainContext/ObjectContext, we need to recursively detach the object graph and attach it to other DomainContext/ObjectContext. Object Graph Single entity can be easily detached and attached from EntitySet where it belongs, [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://akashkava.com/blog/379/detach-entities-recursively-and-attach-to-new-domaincontext-in-entity-framework-and-ria-services/";
		digg_bgcolor = "";
		digg_skin = "";
		digg_window = "";
		digg_title = "Detach+Entities+Recursively+and+Attach+to+New+DomainContext+in+Entity+Framework+and+RIA+Services";
		digg_media = "";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fakashkava.com%2Fblog%2F379%2Fdetach-entities-recursively-and-attach-to-new-domaincontext-in-entity-framework-and-ria-services%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fakashkava.com%2Fblog%2F379%2Fdetach-entities-recursively-and-attach-to-new-domaincontext-in-entity-framework-and-ria-services%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Entity Framework and RIA Services do not allow Entities to be added/removed from cross containers. In order to move Entity from one DomainContext/ObjectContext to another DomainContext/ObjectContext, we need to recursively detach the object graph and attach it to other DomainContext/ObjectContext.</p>
<h2>Object Graph</h2>
<p>Single entity can be easily detached and attached from EntitySet where it belongs, but the problem comes when navigation properties of entity are not empty. Entity object along with navigation properties is called Object Graph because if you notice, navigation property’s navigation property will contain reference to same entity and that will result in endless recursive code for Detach/Attach.</p>
<h2>An entity with the same identity already exists in the EntitySet</h2>
<p>When you try to detach entity from old DomainContext/ObjectContext and attach it to DomainContext/ObjectContext, it may give you an error that entity with same identity already exists and it will throw an exception. In this case we will just simply reuse the existing entity instead of attaching the entity we have.</p>
<h2>Entity cannot be attached to this EntityContainer because it is already attached to another EntityContainer</h2>
<p>In case of ObjectGraph, your root level entity is already detached, but navigation properties are not detached, and while you try to attach your root level entity, it will throw same error for entities that exist in navigation properties.&#160; Because detach method does not recursively detach every entity from navigation properties.</p>
<h2>Attach/Detach Extension Methods</h2>
<p>Finally after brainstorming little, I made following class that will allow you to recursively detach/attach object graphs from DomainContext. You can replace DomainContext to ObjectContext to use it inside Entity Framework.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1357a75c-1e52-42b7-8917-81a262c881ac" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">DomainContext Extensions</div>
<div style="background: #ddd; overflow: auto">
<ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px; white-space: nowrap">
<li><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span></li>
<li style="background: #f3f3f3"><span style="color:#808080">///</span><span style="color:#008000"> DomainContext Extensions</span></li>
<li><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span></li>
<li style="background: #f3f3f3"><span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">DomainContextExtensions</span> {</li>
<li>&nbsp;</li>
<li style="background: #f3f3f3">    <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span></li>
<li>    <span style="color:#808080">///</span><span style="color:#008000"> Recursively Attaches entity loaded from Other DomainContext to </span></li>
<li style="background: #f3f3f3">    <span style="color:#808080">///</span><span style="color:#008000"> current specified DomainContext</span></li>
<li>    <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span></li>
<li style="background: #f3f3f3">    <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;context&quot;&gt;</span><span style="color:#008000">DomainContext where entity will be attached</span><span style="color:#808080">&lt;/param&gt;</span></li>
<li>    <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;entity&quot;&gt;</span><span style="color:#008000">Entity loaded from other DomainContext</span><span style="color:#808080">&lt;/param&gt;</span></li>
<li style="background: #f3f3f3">    <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;returns&gt;&lt;/returns&gt;</span></li>
<li>    <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">Entity</span> Attach(<span style="color:#0000ff">this</span> <span style="color:#2b91af">DomainContext</span> context, <span style="color:#2b91af">Entity</span> entity)</li>
<li style="background: #f3f3f3">    {</li>
<li>        <span style="color:#0000ff">if</span> (entity == <span style="color:#0000ff">null</span> || entity.EntityState != <span style="color:#2b91af">EntityState</span>.Detached)</li>
<li style="background: #f3f3f3">            <span style="color:#0000ff">return</span> entity;</li>
<li>&nbsp;</li>
<li style="background: #f3f3f3">        <span style="color:#2b91af">Entity</span> newEntity = entity;</li>
<li>&nbsp;</li>
<li style="background: #f3f3f3">        <span style="color:#2b91af">Entity</span>[] list = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Entity</span>[] { entity };</li>
<li>        <span style="color:#0000ff">foreach</span> (<span style="color:#2b91af">Entity</span> c <span style="color:#0000ff">in</span> context.EntityContainer.LoadEntities(list, </li>
<li style="background: #f3f3f3">            <span style="color:#2b91af">LoadBehavior</span>.MergeIntoCurrent))</li>
<li>        {</li>
<li style="background: #f3f3f3">            newEntity = c;</li>
<li>            <span style="color:#0000ff">break</span>;</li>
<li style="background: #f3f3f3">        }</li>
<li>&nbsp;</li>
<li style="background: #f3f3f3">        <span style="color:#008000">// recursively attach all entities..</span></li>
<li>        <span style="color:#2b91af">Type</span> entityType = <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">Entity</span>);</li>
<li style="background: #f3f3f3">&nbsp;</li>
<li>        <span style="color:#008000">// get all navigation properties&#8230;</span></li>
<li style="background: #f3f3f3">        <span style="color:#2b91af">Type</span> type = entity.GetType();</li>
<li>        <span style="color:#0000ff">foreach</span> (<span style="color:#0000ff">var</span> item <span style="color:#0000ff">in</span> type.GetProperties())</li>
<li style="background: #f3f3f3">        {</li>
<li>            <span style="color:#0000ff">if</span> (entityType.IsAssignableFrom(item.PropertyType))</li>
<li style="background: #f3f3f3">            {</li>
<li>                <span style="color:#2b91af">Entity</span> navEntity = Attach(context, item.GetValue(entity, <span style="color:#0000ff">null</span>) </li>
<li style="background: #f3f3f3">                    <span style="color:#0000ff">as</span> <span style="color:#2b91af">Entity</span>);</li>
<li>                item.SetValue(newEntity,navEntity, <span style="color:#0000ff">null</span>);</li>
<li style="background: #f3f3f3">                <span style="color:#0000ff">continue</span>;</li>
<li>            }</li>
<li style="background: #f3f3f3">            <span style="color:#0000ff">if</span> (item.PropertyType.Name.StartsWith(<span style="color:#a31515">&quot;EntityCollection&quot;</span>))</li>
<li>            {</li>
<li style="background: #f3f3f3">                <span style="color:#2b91af">IEnumerable</span> coll = item.GetValue(entity, <span style="color:#0000ff">null</span>) <span style="color:#0000ff">as</span> <span style="color:#2b91af">IEnumerable</span>;</li>
<li>                <span style="color:#2b91af">List</span>&lt;<span style="color:#2b91af">Entity</span>&gt; newList = <span style="color:#0000ff">new</span> <span style="color:#2b91af">List</span>&lt;<span style="color:#2b91af">Entity</span>&gt;();</li>
<li style="background: #f3f3f3">                <span style="color:#0000ff">foreach</span> (<span style="color:#2b91af">Entity</span> child <span style="color:#0000ff">in</span> coll)</li>
<li>                {</li>
<li style="background: #f3f3f3">                    newList.Add(Attach(context, child));</li>
<li>                }</li>
<li style="background: #f3f3f3">                <span style="color:#0000ff">dynamic</span> dcoll = item.GetValue(newEntity,<span style="color:#0000ff">null</span>);</li>
<li>                <span style="color:#0000ff">foreach</span> (<span style="color:#0000ff">dynamic</span> child <span style="color:#0000ff">in</span> newList)</li>
<li style="background: #f3f3f3">                {</li>
<li>                    dcoll.Add(child);</li>
<li style="background: #f3f3f3">                }</li>
<li>            }</li>
<li style="background: #f3f3f3">        }</li>
<li>        <span style="color:#0000ff">return</span> newEntity;</li>
<li style="background: #f3f3f3">    }</li>
<li>&nbsp;</li>
<li style="background: #f3f3f3">    <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span></li>
<li>    <span style="color:#808080">///</span><span style="color:#008000"> Recursively detaches entities from DomainContext, this </span></li>
<li style="background: #f3f3f3">    <span style="color:#808080">///</span><span style="color:#008000"> method detaches every navigation properties</span></li>
<li>    <span style="color:#808080">///</span><span style="color:#008000"> of current Entity as well.</span></li>
<li style="background: #f3f3f3">    <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span></li>
<li>    <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;context&quot;&gt;&lt;/param&gt;</span></li>
<li style="background: #f3f3f3">    <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;entity&quot;&gt;&lt;/param&gt;</span></li>
<li>    <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> Detach(<span style="color:#0000ff">this</span> <span style="color:#2b91af">DomainContext</span> context, <span style="color:#2b91af">Entity</span> entity)</li>
<li style="background: #f3f3f3">    {</li>
<li>        <span style="color:#0000ff">if</span> (entity == <span style="color:#0000ff">null</span> || entity.EntityState == <span style="color:#2b91af">EntityState</span>.Detached)</li>
<li style="background: #f3f3f3">            <span style="color:#0000ff">return</span>;</li>
<li>        <span style="color:#2b91af">EntitySet</span> nes = context.EntityContainer.GetEntitySet(entity.GetType());</li>
<li style="background: #f3f3f3">        nes.Detach(entity);</li>
<li>&nbsp;</li>
<li style="background: #f3f3f3">        <span style="color:#2b91af">Type</span> entityType = <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">Entity</span>);</li>
<li>&nbsp;</li>
<li style="background: #f3f3f3">        <span style="color:#008000">// get all navigation properties&#8230;</span></li>
<li>        <span style="color:#2b91af">Type</span> type = entity.GetType();</li>
<li style="background: #f3f3f3">        <span style="color:#0000ff">foreach</span> (<span style="color:#0000ff">var</span> item <span style="color:#0000ff">in</span> type.GetProperties())</li>
<li>        {</li>
<li style="background: #f3f3f3">            <span style="color:#0000ff">if</span> (entityType.IsAssignableFrom(item.PropertyType))</li>
<li>            {</li>
<li style="background: #f3f3f3">                Detach(context,item.GetValue(entity, <span style="color:#0000ff">null</span>) <span style="color:#0000ff">as</span> <span style="color:#2b91af">Entity</span>);</li>
<li>                <span style="color:#0000ff">continue</span>;</li>
<li style="background: #f3f3f3">            }</li>
<li>            <span style="color:#0000ff">if</span> (item.PropertyType.Name.StartsWith(<span style="color:#a31515">&quot;EntityCollection&quot;</span>))</li>
<li style="background: #f3f3f3">            {</li>
<li>                <span style="color:#2b91af">IEnumerable</span> coll = item.GetValue(entity, <span style="color:#0000ff">null</span>) <span style="color:#0000ff">as</span> <span style="color:#2b91af">IEnumerable</span>;</li>
<li style="background: #f3f3f3">                <span style="color:#0000ff">foreach</span> (<span style="color:#2b91af">Entity</span> child <span style="color:#0000ff">in</span> coll)</li>
<li>                {</li>
<li style="background: #f3f3f3">                    Detach(context,child);</li>
<li>                }</li>
<li style="background: #f3f3f3">            }</li>
<li>        }</li>
<li style="background: #f3f3f3">    }</li>
<li>&nbsp;</li>
<li style="background: #f3f3f3">}</li>
</ol></div>
</p></div>
</p></div>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fakashkava.com%2Fblog%2F379%2Fdetach-entities-recursively-and-attach-to-new-domaincontext-in-entity-framework-and-ria-services%2F&amp;title=Detach%20Entities%20Recursively%20and%20Attach%20to%20New%20DomainContext%20in%20Entity%20Framework%20and%20RIA%20Services"><img src="http://akashkava.com/blog/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://akashkava.com/blog/379/detach-entities-recursively-and-attach-to-new-domaincontext-in-entity-framework-and-ria-services/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>UI Atoms 1.5.8 Released</title>
		<link>http://akashkava.com/blog/378/ui-atoms-1-5-8-released/</link>
		<comments>http://akashkava.com/blog/378/ui-atoms-1-5-8-released/#comments</comments>
		<pubDate>Tue, 11 Jan 2011 11:47:00 +0000</pubDate>
		<dc:creator>Akash Kava</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Customize]]></category>
		<category><![CDATA[DataForm]]></category>
		<category><![CDATA[Form Designer]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Release]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[UI Atoms]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://akashkava.com/blog/378/ui-atoms-1-5-8-released/</guid>
		<description><![CDATA[We are happy to announce new release of UI Atoms 1.5.8 with following new features. UI Atoms for WPF 4.0 In this release of UI Atoms, we have a new library of dlls specially designed for WPF 4.0, which now includes support for Visual State Managers and renders everything in WPF 4.0 presentation. You can [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://akashkava.com/blog/378/ui-atoms-1-5-8-released/";
		digg_bgcolor = "";
		digg_skin = "";
		digg_window = "";
		digg_title = "UI+Atoms+1.5.8+Released";
		digg_media = "";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fakashkava.com%2Fblog%2F378%2Fui-atoms-1-5-8-released%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fakashkava.com%2Fblog%2F378%2Fui-atoms-1-5-8-released%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>We are happy to announce new release of UI Atoms 1.5.8 with following new features.</p>
<h2>UI Atoms for WPF 4.0</h2>
<p>In this release of UI Atoms, we have a new library of dlls specially designed for WPF 4.0, which now includes support for Visual State Managers and renders everything in WPF 4.0 presentation. You can find Bin.Net4 folder inside WPF, that contains libraries only for WPF 4.0 version.</p>
<h2>AtomForm Label Alignment for Silverlight and WPF</h2>
<p><a href="http://akashkava.com/blog/wp-content/uploads/2011/01/Silverlight-Form-Label-Alignment.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="Silverlight-Form-Label-Alignment" border="0" alt="Silverlight-Form-Label-Alignment" src="http://akashkava.com/blog/wp-content/uploads/2011/01/Silverlight-Form-Label-Alignment_thumb.png" width="592" height="294" /></a></p>
<p>AtomForm now provides following two properties,</p>
<ul>
<li>LabelHorizontalAlignment property that can align the label horizontally in the form item. </li>
<li>LabelVerticalAlignment property that can align the label vertically in the form item. </li>
</ul>
<h2>Label Can now contain string or UI Element object</h2>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fcb2ac16-ff98-412b-bd36-3a1216a32b41" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">Rich Label Format</div>
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;">
<li><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomTextBox</span><span style="color:#ff0000"> HorizontalAlignment</span><span style="color:#0000ff">=&quot;Stretch&quot;</span> </li>
<li style="background: #f3f3f3">               <span style="color:#ff0000"> Text</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> Path</span><span style="color:#0000ff">=ProjectName,</span><span style="color:#ff0000"> Mode</span><span style="color:#0000ff">=TwoWay}&quot;</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;Auto&quot; &gt;</span></li>
<li>    <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomForm.Label</span><span style="color:#0000ff">&gt;</span></li>
<li style="background: #f3f3f3">        <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> Orientation</span><span style="color:#0000ff">=&quot;Horizontal&quot;&gt;</span></li>
<li>            <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBlock</span><span style="color:#0000ff">&gt;</span><span style="color:#a31515">Name:</span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">TextBlock</span><span style="color:#0000ff">&gt;</span></li>
<li style="background: #f3f3f3">            <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Image</span><span style="color:#ff0000"> Source</span><span style="color:#0000ff">=&quot;/PrismTest;component/Images/Logo.png&quot;</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;16&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;16&quot; /&gt;</span></li>
<li>        <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span></li>
<li style="background: #f3f3f3">    <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomForm.Label</span><span style="color:#0000ff">&gt;</span></li>
<li><span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomTextBox</span><span style="color:#0000ff">&gt;</span></li>
</ol></div>
</p></div>
</p></div>
<p><a href="http://akashkava.com/blog/wp-content/uploads/2011/01/Rich-Label-Silverlight-WPF-Form.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="Rich-Label-Silverlight-WPF-Form" border="0" alt="Rich-Label-Silverlight-WPF-Form" src="http://akashkava.com/blog/wp-content/uploads/2011/01/Rich-Label-Silverlight-WPF-Form_thumb.png" width="283" height="163" /></a></p>
<p>&#160;</p>
<h2>Advanced Quick Form Designer</h2>
<p>Typing Tags with all Bindings could be quite time consuming, where it involves moving items up and down, deleting and adding new Form Items. Advanced Quick Form Designer resolves all this problems by giving you state of art designer, which provides one quick grid to enter all necessary information. However the form designer works well even for existing forms, and you can generate entire new form by selecting some Type as well.</p>
<p><a href="http://akashkava.com/blog/wp-content/uploads/2011/01/Advanced-Silverlight-WPF-Form-Designer.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="Advanced-Silverlight-WPF-Form-Designer" border="0" alt="Advanced-Silverlight-WPF-Form-Designer" src="http://akashkava.com/blog/wp-content/uploads/2011/01/Advanced-Silverlight-WPF-Form-Designer_thumb.png" width="584" height="500" /></a></p>
<p>As you see, type of control can be changed that will represent the form item and corresponding binding property can be changed as well. Just with simple one click, you can move items up and down or delete them. You can add a new control that is defaulted to AtomTextBox at the top, you can change default control to add multiple one after another very easily. Also you can click “Generate From Type” to select any Business Object Type and generate a brand new form.</p>
<p><a href="http://akashkava.com/blog/wp-content/uploads/2011/01/Generate-Form-From-Type-Silverlight-WPF.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="Generate-Form-From-Type-Silverlight-WPF" border="0" alt="Generate-Form-From-Type-Silverlight-WPF" src="http://akashkava.com/blog/wp-content/uploads/2011/01/Generate-Form-From-Type-Silverlight-WPF_thumb.png" width="420" height="420" /></a></p>
<p>Selecting type will automatically generate form with its bindings.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fakashkava.com%2Fblog%2F378%2Fui-atoms-1-5-8-released%2F&amp;title=UI%20Atoms%201.5.8%20Released"><img src="http://akashkava.com/blog/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://akashkava.com/blog/378/ui-atoms-1-5-8-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MVVM + AtomForm + Cascaded ComboBoxes for WPF &amp; Silverlight</title>
		<link>http://akashkava.com/blog/361/mvvm-atomform-cascaded-comboboxes/</link>
		<comments>http://akashkava.com/blog/361/mvvm-atomform-cascaded-comboboxes/#comments</comments>
		<pubDate>Thu, 21 Oct 2010 11:47:00 +0000</pubDate>
		<dc:creator>Akash Kava</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[AtomForm]]></category>
		<category><![CDATA[Cacaded]]></category>
		<category><![CDATA[ComboBox]]></category>
		<category><![CDATA[DataForm]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[MVVM]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[UI Atoms]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://akashkava.com/blog/361/mvvm-atomform-cascaded-comboboxes/</guid>
		<description><![CDATA[UI Atoms version 1.2.22 resolves Cascaded ComboBoxes issue in MVVM pattern. Advanced AtomForm is now capable of handling cascaded ComboBoxes with MVVM and it also integrates well with third party controls. Recently we identified few issues with MVVM implementation in Silverlight regarding ComboBoxes. ComboBox looses its “SelectedValue” binding once the ItemsSource of ComboBox changes. This [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://akashkava.com/blog/361/mvvm-atomform-cascaded-comboboxes/";
		digg_bgcolor = "";
		digg_skin = "";
		digg_window = "";
		digg_title = "MVVM+%2B+AtomForm+%2B+Cascaded+ComboBoxes+for+WPF+%26amp%3B+Silverlight";
		digg_media = "";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fakashkava.com%2Fblog%2F361%2Fmvvm-atomform-cascaded-comboboxes%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fakashkava.com%2Fblog%2F361%2Fmvvm-atomform-cascaded-comboboxes%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>UI Atoms version 1.2.22 resolves Cascaded ComboBoxes issue in MVVM pattern. Advanced AtomForm is now capable of handling cascaded ComboBoxes with MVVM and it also integrates well with third party controls.</p>
<p>Recently we identified few issues with MVVM implementation in Silverlight regarding ComboBoxes. ComboBox looses its “SelectedValue” binding once the ItemsSource of ComboBox changes. This needed some workaround as well as Modifying DataForm is very painful as you may need very complex form designs in regular business applications.</p>
<h2>1. Create Models</h2>
<p>Lets assume we need to edit a Customer’s Country and City, as we change the Country the list of cities should change it. Problem with existing ComboBox and DataForm is, as soon as list of cities changes, ComboBox’s SelectedValue binding vanishes. So lets create Customer Model first.</p>
<p>&#160;</p>
<p><a href="http://akashkava.com/blog/wp-content/uploads/2010/10/MVVMViewModels.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="MVVM-View-Models" border="0" alt="MVVM-View-Models" src="http://akashkava.com/blog/wp-content/uploads/2010/10/MVVMViewModels_thumb.png" width="576" height="451" /></a> </p>
<p>Each of properties in CustomerViewModel raises PropertyChanged event for corresponding properties when modified.</p>
<p>When selected customer changes, SelectedCountry also changes and which changes Cities property, so in drop down we can display the list of cities of selected country.</p>
<p>Important:</p>
<blockquote><p>Your SelectedCountry property, where you need Change of Selection event must not raise PropertyChanged event in “set” method as shown below…, however you may turn it off or on based on your UI behavior. WPF has no problem but Silverlight has issues and it works better if PropertyChanged event is not raised. </p>
</blockquote>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3d18f7bc-84e2-4abf-abc6-ed36b294659b" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">Selected Country Property</div>
<div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap">        <span style="color:#0000ff">public</span> <span style="color:#2b91af">Country</span> SelectedCountry<br />         {<br />             <span style="color:#0000ff">get</span><br />             {<br />                 <span style="color:#0000ff">return</span> _SelectedCountry;<br />             }<br />             <span style="color:#0000ff">set</span><br />             {<br />                 _SelectedCountry = <span style="color:#0000ff">value</span>;<br />                 <span style="color:#008000">//if (PropertyChanged != null)</span><br />                 <span style="color:#008000">//    PropertyChanged(this, new PropertyChangedEventArgs(&quot;SelectedCountry&quot;));</span><br />                 <span style="color:#0000ff">if</span> (_SelectedCountry != <span style="color:#0000ff">null</span>)<br />                 {<br />                     Cities = _SelectedCountry.Cities;<br />                 }<br />             }<br />         }</div>
</p></div>
</p></div>
<h2>2. Create Master View</h2>
<p>Master View control declares grid with two columns, left side displaying list of customers and on right side displaying details of the selected customer.</p>
</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:96234641-c16b-4664-9f6b-9c61573d7bfe" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">MainPage Master View Control</div>
<div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">UserControl</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;PrismTest.MainPage&quot;</span><br />    <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br />    <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br />    <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">d</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;</span><br />    <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">mc</span><span style="color:#0000ff">=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;</span><br />    <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">ns</span><span style="color:#0000ff">=&quot;http://uiatoms.neurospeech.com/silverlight&quot;</span><br />    <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">local</span><span style="color:#0000ff">=&quot;clr-namespace:PrismTest&quot;</span><br />    <span style="color:#ff0000"> mc</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Ignorable</span><span style="color:#0000ff">=&quot;d&quot;</span><br />    <span style="color:#ff0000"> d</span><span style="color:#0000ff">:</span><span style="color:#ff0000">DesignHeight</span><span style="color:#0000ff">=&quot;300&quot;</span><span style="color:#ff0000"> d</span><span style="color:#0000ff">:</span><span style="color:#ff0000">DesignWidth</span><span style="color:#0000ff">=&quot;400&quot;&gt;</span><br /> <span style="color:#a31515">    </span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">UserControl.Resources</span><span style="color:#0000ff">&gt;</span><br /> <span style="color:#a31515">        </span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">ViewModelLocator</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Key</span><span style="color:#0000ff">=&quot;locator&quot;/&gt;</span><br /> <span style="color:#a31515">    </span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">UserControl.Resources</span><span style="color:#0000ff">&gt;</span><br /> <span style="color:#a31515">    </span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;LayoutRoot&quot;</span><span style="color:#ff0000"> Background</span><span style="color:#0000ff">=&quot;White&quot;&gt;</span><br /> <span style="color:#a31515">        </span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid.RowDefinitions</span><span style="color:#0000ff">&gt;</span><br /> <span style="color:#a31515">            </span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">RowDefinition</span><span style="color:#0000ff">/&gt;</span><br /> <span style="color:#a31515">            </span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">RowDefinition</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;400&quot; /&gt;</span><br /> <span style="color:#a31515">        </span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid.RowDefinitions</span><span style="color:#0000ff">&gt;</span><br /> <span style="color:#a31515">        </span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid.ColumnDefinitions</span><span style="color:#0000ff">&gt;</span><br /> <span style="color:#a31515">            </span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ColumnDefinition</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;200&quot; /&gt;</span><br /> <span style="color:#a31515">            </span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ColumnDefinition</span><span style="color:#0000ff"> /&gt;</span><br /> <span style="color:#a31515">        </span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid.ColumnDefinitions</span><span style="color:#0000ff">&gt;</span><br /> <span style="color:#a31515">        </span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ListBox</span> <br />            <span style="color:#ff0000"> DisplayMemberPath</span><span style="color:#0000ff">=&quot;Name&quot;</span><br />            <span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;list&quot;</span><br />            <span style="color:#ff0000"> SelectedItem</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> ViewModel</span><span style="color:#0000ff">.SelectedCustomer,</span><span style="color:#ff0000">Source</span><span style="color:#0000ff">={</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> locator}</span><span style="color:#0000ff">,</span><span style="color:#ff0000"> Mode</span><span style="color:#0000ff">=TwoWay}&quot;</span><br />            <span style="color:#ff0000"> ItemsSource</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> ViewModel</span><span style="color:#0000ff">.Customers,</span><span style="color:#ff0000">Source</span><span style="color:#0000ff">={</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> locator}}</span><span style="color:#0000ff">&quot; /&gt;</span><br /> <span style="color:#a31515">        </span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">CustomerView</span><br />            <span style="color:#ff0000"> Grid.Column</span><span style="color:#0000ff">=&quot;1&quot;</span> <span style="color:#0000ff"> /&gt;</span><br /> <span style="color:#a31515">        </span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomTraceView</span> <br />            <span style="color:#ff0000"> Grid.Row</span><span style="color:#0000ff">=&quot;1&quot;</span><span style="color:#ff0000"> Grid.ColumnSpan</span><span style="color:#0000ff">=&quot;2&quot;/&gt;</span><br /> <span style="color:#a31515">    </span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br /> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">UserControl</span><span style="color:#0000ff">&gt;</span></div>
</p></div>
</p></div>
</p>
<p>Lets analyze Bindings,</p>
<ol>
<li>ListBox’s ItemsSource is bound to ViewModel.Customers which returns list of available customers. </li>
<li>ListBox’s SelectedItem is bound (two way) to ViewModel.SelectedCustomer. </li>
</ol>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:84aa2d82-f688-4de0-802a-75749ed7d12c" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">Customer View Control</div>
<div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">UserControl</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;PrismTest.CustomerView&quot;</span><br />    <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br />    <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br />    <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">d</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;</span><br />    <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">mc</span><span style="color:#0000ff">=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;</span><br />    <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">ns</span><span style="color:#0000ff">=&quot;http://uiatoms.neurospeech.com/silverlight&quot;</span><br />    <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">local</span><span style="color:#0000ff">=&quot;clr-namespace:PrismTest&quot;</span><br />    <span style="color:#ff0000"> mc</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Ignorable</span><span style="color:#0000ff">=&quot;d&quot;</span><br />    <span style="color:#ff0000"> d</span><span style="color:#0000ff">:</span><span style="color:#ff0000">DesignHeight</span><span style="color:#0000ff">=&quot;300&quot;</span><span style="color:#ff0000"> d</span><span style="color:#0000ff">:</span><span style="color:#ff0000">DesignWidth</span><span style="color:#0000ff">=&quot;400&quot;&gt;</span><br /> <span style="color:#a31515">    </span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">UserControl.Resources</span><span style="color:#0000ff">&gt;</span><br /> <span style="color:#a31515">        </span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">ViewModelLocator</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Key</span><span style="color:#0000ff">=&quot;locator&quot;/&gt;</span><br /> <span style="color:#a31515">    </span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">UserControl.Resources</span><span style="color:#0000ff">&gt;</span><br /> <span style="color:#a31515">    </span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomForm</span><span style="color:#ff0000"> DataContext</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> ViewModel</span><span style="color:#0000ff">.SelectedCustomer,</span><span style="color:#ff0000">Source</span><span style="color:#0000ff">={</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> locator}}</span><span style="color:#0000ff">&quot;&gt;</span><br /> <span style="color:#a31515">        </span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomTextBox</span><span style="color:#ff0000"> Text</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> Name</span><span style="color:#0000ff">,</span><span style="color:#ff0000"> Mode</span><span style="color:#0000ff">=TwoWay}&quot;</span> <br />                        <span style="color:#ff0000"> ns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">AtomForm.Label</span><span style="color:#0000ff">=&quot;Name:&quot; /&gt;</span><br /> <span style="color:#a31515">        </span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomComboBox</span><span style="color:#ff0000"> ns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">AtomForm.Label</span><span style="color:#0000ff">=&quot;Country:&quot;</span> <br />                         <span style="color:#ff0000"> SelectedValuePath</span><span style="color:#0000ff">=&quot;CountryID&quot;</span><br />                         <span style="color:#ff0000"> DisplayMemberPath</span><span style="color:#0000ff">=&quot;Name&quot;</span><br />                         <span style="color:#ff0000"> ItemsSource</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> ViewModel</span><span style="color:#0000ff">.Countries,</span><span style="color:#ff0000">Source</span><span style="color:#0000ff">={</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> locator}}</span><span style="color:#0000ff">&quot;</span><br />                         <span style="color:#ff0000"> SelectedItem</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> ViewModel</span><span style="color:#0000ff">.SelectedCountry,</span><span style="color:#ff0000">Source</span><span style="color:#0000ff">={</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> locator}</span><span style="color:#0000ff">,</span><span style="color:#ff0000"> Mode</span><span style="color:#0000ff">=TwoWay}&quot;</span><br />                         <span style="color:#ff0000"> SelectedValue</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> CountryID</span><span style="color:#0000ff">,</span><span style="color:#ff0000"> Mode</span><span style="color:#0000ff">=TwoWay}&quot;</span><br />                         <span style="color:#0000ff"> /&gt;</span><br /> <span style="color:#a31515">        </span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomComboBox</span><span style="color:#ff0000"> ns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">AtomForm.Label</span><span style="color:#0000ff">=&quot;City:&quot;</span>                          <br />                         <span style="color:#ff0000"> SelectedValuePath</span><span style="color:#0000ff">=&quot;CityID&quot;</span><br />                         <span style="color:#ff0000"> DisplayMemberPath</span><span style="color:#0000ff">=&quot;Name&quot;</span><br />                         <span style="color:#ff0000"> ItemsSource</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> ViewModel</span><span style="color:#0000ff">.Cities,</span><span style="color:#ff0000">Source</span><span style="color:#0000ff">={</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> locator}}</span><span style="color:#0000ff">&quot;</span><br />                         <span style="color:#ff0000"> SelectedValue</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> CityID</span><span style="color:#0000ff">,</span><span style="color:#ff0000"> Mode</span><span style="color:#0000ff">=TwoWay}&quot;</span><br />                         <span style="color:#0000ff"> /&gt;</span><br /> <span style="color:#a31515">    </span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">ns</span><span style="color:#0000ff">:</span><span style="color:#a31515">AtomForm</span><span style="color:#0000ff">&gt;</span><span style="color:#a31515">    </span><br /> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">UserControl</span><span style="color:#0000ff">&gt;</span></div>
</p></div>
</p></div>
<p>Lets analyze the bindings,</p>
<ol>
<li>AtomForm’s DataContext is bound to SelectedCustomer of ViewModel, which comes from SelectedItem of Parent Control </li>
<li>AtomTextBox’s&#160; Text is bound to Name (of AtomForm’s DataContext’s binding) with Mode=TwoWay </li>
<li>AtomComboBox
<ol>
<li>ItemsSource is bound to ViewModel.Countries which returns list of countries. </li>
<li>SelectedValue is bound to CountryID (of AtomForm’s DataContext’s binding) with Mode=TwoWay </li>
<li>SelectedItem is bound to ViewModel.SelectedCountry, which triggers change of SelectedCountry property on ViewModel which changes list of cities. </li>
</ol>
</li>
<li>AtomComboBox (this is the one that’s tricky, normal ComboBox does not work here)
<ol>
<li>ItemsSource is bound to ViewModel.Cities which returns list of cities of SelectedCountry. </li>
<li>SelectedValue is bound to CityID (of AtomForm’s DataContext’s binding) with Mode=TwoWay </li>
</ol>
</li>
</ol>
<p>&#160;</p>
</p>
</p>
<h2>3. Cascaded ComboBox</h2>
<p>You can see that the cascaded ComboBox work well with AtomForm and AtomComboBox and its easy to design AtomForm with MVVM with so much less code then that of DataForm and ComboBoxes.</p>
<p><a href="http://akashkava.com/blog/wp-content/uploads/2010/10/Form.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Form" border="0" alt="Form" src="http://akashkava.com/blog/wp-content/uploads/2010/10/Form_thumb.png" width="591" height="161" /></a> </p>
<p>Please download the latest version of <a href="http://uiatoms.neurospeech.com/v1/download/UIAtoms2010Demo.zip" target="_blank">UI Atoms 2010 suite</a> to try MVVM + AtomForm + Cascaded ComboBoxes.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fakashkava.com%2Fblog%2F361%2Fmvvm-atomform-cascaded-comboboxes%2F&amp;title=MVVM%20%2B%20AtomForm%20%2B%20Cascaded%20ComboBoxes%20for%20WPF%20%26amp%3B%20Silverlight"><img src="http://akashkava.com/blog/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://akashkava.com/blog/361/mvvm-atomform-cascaded-comboboxes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NeuroSpeech releases XamlGenerator 1.0</title>
		<link>http://akashkava.com/blog/356/neurospeech-releases-xamlgenerator-1-0/</link>
		<comments>http://akashkava.com/blog/356/neurospeech-releases-xamlgenerator-1-0/#comments</comments>
		<pubDate>Tue, 28 Sep 2010 16:51:00 +0000</pubDate>
		<dc:creator>Akash Kava</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Generator]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[Xaml]]></category>

		<guid isPermaLink="false">http://akashkava.com/blog/356/neurospeech-releases-xamlgenerator-1-0/</guid>
		<description><![CDATA[XamlGenerator is Code Behind source code Generator for Xaml. Xaml Code Behind Generator makes it easier to generate Code Behind designer code from XAML, where code can be used at places where Xaml Services are not accessible. Features Using XAML 2009 in Silverlight and WPF Reusing Xaml Business Pages in Silverlight and WPF Support for [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://akashkava.com/blog/356/neurospeech-releases-xamlgenerator-1-0/";
		digg_bgcolor = "";
		digg_skin = "";
		digg_window = "";
		digg_title = "NeuroSpeech+releases+XamlGenerator+1.0";
		digg_media = "";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fakashkava.com%2Fblog%2F356%2Fneurospeech-releases-xamlgenerator-1-0%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fakashkava.com%2Fblog%2F356%2Fneurospeech-releases-xamlgenerator-1-0%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>XamlGenerator is Code Behind source code Generator for Xaml. </p>
<p>Xaml Code Behind Generator makes it easier to generate Code Behind designer code from XAML, where code can be used at places where Xaml Services are not accessible.   <br /><b>Features</b></p>
<ol>
<li>Using XAML 2009 in Silverlight and WPF </li>
<li>Reusing Xaml Business Pages in Silverlight and WPF </li>
<li>Support for User Controls derived from any Control </li>
<li>Using Complied code instead of BAML </li>
<li>Improving speed of XAML runtime </li>
<li>Using XAML to generate code to be used in ASP.NET, Server Core etc, where XAML Services are not available </li>
<li>Generated code is pure .NET 2.0 compliant, and you can target xaml objects to run in earlier .NET version too. </li>
<li>You can also create Xaml for WinForms and use it for your .NET 2.0 projects, however please notice, the features of WPF will not be available, it can only create object hierarchies based on XAML, but it can not give you binding etc features. </li>
<li>x:Name support for Resources, very useful for MVVM Pattern </li>
<li>Support for Custom Extension with Custom Code Generator</li>
</ol>
<h3>Xaml Code Generator</h3>
<p> .Net 4 introduces Xaml Services that can load Xaml Object Trees and it provides great deal in terms of intellisense and code behind facilities, however this can only be used where Xaml Services are installed. Also it is quite painful to debug and hide the generated baml resources, that actually is quite easy to disassemble and view the source.  <br />Xaml Code Generator can easily solve these problems by creating source code equivalent to loading object via Xaml Services. Instead, once generated, the performance of source code is quite faster then baml and xaml. Since ASP.NET and WinForms, code behind files did serve great support to link the UI and Code. However in WPF and Silverlight does not support simple references to code behind objects except events. There are work arounds, but we decided to create Xaml Code Generator that will solve lot of problems.<br />
<h4>Benefits to WPF and Silverlight</h4>
<ol>
<li>Xaml pages can now use x:Reference markup extension </li>
<li>Xaml pages can support generic type parameters </li>
<li>Xaml page can now derive from any control/panel </li>
<li>Xaml can easily reference any expression that involves code behind operation including &quot;this&quot; keyword </li>
<li>By using custom Xaml markup extensions, you can reuse Xaml between WPF and Silverlight</li>
</ol>
<h4>Known limitations with Xaml Code Generated files</h4>
<ol>
<li>Control Templates and Styles must use respective WPF/Silverlight markup only </li>
<li>No code behind files can be generated for Control Templates and Styles </li>
<li>Xaml pages can not be used with Navigation Urls </li>
<li>Instead code generated files are simply source code equivalent of Xaml, and they should be treated as .Net CLR Objects instead of Xaml Pages and there exists no equivalent baml resources</li>
</ol>
<h4>So how to use benefits of Code Generator as well as XAML</h4>
<p> We recommend following pattern to make use of best of both the worlds
<ol>
<li>Create Main Application Window/Page as regular Xaml </li>
<li>Instead of User Controls, use Xaml derived from Equivalent controls, such as StackPanel, Grid etc, and use them in Main Window/Pages </li>
<li>In this pattern, generated CLR objects of xaml will perform exactly same</li>
</ol>
<h3>Why Generate source code from XAML?</h3>
<p> Xaml and Xaml Services are great, they give a huge benefit in terms of runtime model loading and behaviour. For larger systems, and for complex enterprise applications Xaml is perfect. But we still have lot of code in .NET 2.0 and applications that are still heavily dependent on the components that do not support Xaml Services.  <br />Plus, shift of paradigm from code behind to view model is quite painful. Infact ability to use more code behind features is quite needed for current generation.  <br />Debugging Xaml is quite painful still, we still have lot of logic that lies in functional code and there is little more time still before we reach to completely modelled code.  <br />Here are few benefits outlined of generated code,
<ol>
<li>View Model can be replaced by Code behind, as we can easily reference xc:This and xc:Ref extensions </li>
<li>Debugging c# code can be easier which involves more complex UI designs </li>
<li>Xaml Generated can generate anything, even non UI code </li>
<li>You can even use Xaml Generator in your DSL tool</li>
</ol>
<p>For more details, please visit, <a title="http://xamlgenerator.codeplex.com/" href="http://xamlgenerator.codeplex.com/">http://xamlgenerator.codeplex.com/</a></p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fakashkava.com%2Fblog%2F356%2Fneurospeech-releases-xamlgenerator-1-0%2F&amp;title=NeuroSpeech%20releases%20XamlGenerator%201.0"><img src="http://akashkava.com/blog/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://akashkava.com/blog/356/neurospeech-releases-xamlgenerator-1-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to customize AtomForm Label Field using Expression Blend?</title>
		<link>http://akashkava.com/blog/347/how-to-customize-atomform-label-field-using-expression-blend/</link>
		<comments>http://akashkava.com/blog/347/how-to-customize-atomform-label-field-using-expression-blend/#comments</comments>
		<pubDate>Sat, 25 Sep 2010 17:27:55 +0000</pubDate>
		<dc:creator>Akash Kava</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[AtomForm]]></category>
		<category><![CDATA[Customize]]></category>
		<category><![CDATA[Item Template]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[UI Atoms]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://akashkava.com/blog/347/how-to-customize-atomform-label-field-using-expression-blend/</guid>
		<description><![CDATA[This tutorial outlines how to customize UI Atoms’ AtomForm appearance and layout simply by customizing its ItemContainerStyle. AtomForm is derived from ItemsControl, and ItemsControl declares ItemContainerStyle which can customize the template of individual items that are being displayed. UI Atoms give you complete freedom of how to change your look and feel very easily by [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://akashkava.com/blog/347/how-to-customize-atomform-label-field-using-expression-blend/";
		digg_bgcolor = "";
		digg_skin = "";
		digg_window = "";
		digg_title = "How+to+customize+AtomForm+Label+Field+using+Expression+Blend%3F";
		digg_media = "";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fakashkava.com%2Fblog%2F347%2Fhow-to-customize-atomform-label-field-using-expression-blend%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fakashkava.com%2Fblog%2F347%2Fhow-to-customize-atomform-label-field-using-expression-blend%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>This tutorial outlines how to customize UI Atoms’ AtomForm appearance and layout simply by customizing its ItemContainerStyle.</p>
<p>AtomForm is derived from ItemsControl, and ItemsControl declares ItemContainerStyle which can customize the template of individual items that are being displayed. UI Atoms give you complete freedom of how to change your look and feel very easily by just adding a simple template in your resource dictionary.</p>
<p>&#160;</p>
<h2>Create New Item Container Style</h2>
<p>To do this, open your xaml page in the Expression Blend and right click on the AtomForm. And choose Edit Additional Templates, and Select Edit Generated Item Container (ItemContainerStyle) and then click on “Edit a copy…”</p>
</p>
<p> <a href="http://akashkava.com/blog/wp-content/uploads/2010/09/SelectItemContainerStyle1.png"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="SelectItemContainerStyle" border="0" alt="SelectItemContainerStyle" src="http://akashkava.com/blog/wp-content/uploads/2010/09/SelectItemContainerStyle_thumb1.png" width="644" height="480" /></a>
<p>Then choose a location to keep your style in,</p>
<p><a href="http://akashkava.com/blog/wp-content/uploads/2010/09/ChooseStyle1.png"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="ChooseStyle" border="0" alt="ChooseStyle" src="http://akashkava.com/blog/wp-content/uploads/2010/09/ChooseStyle_thumb1.png" width="644" height="482" /></a> </p>
<p>Once the style editor is open, right click on “Style” and click on “Edit Template” and then click on “Edit Current” </p>
<p><a href="http://akashkava.com/blog/wp-content/uploads/2010/09/ChooseCurrent.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="ChooseCurrent" border="0" alt="ChooseCurrent" src="http://akashkava.com/blog/wp-content/uploads/2010/09/ChooseCurrent_thumb.png" width="487" height="326" /></a></p>
<p>Now you will see the Item Container Style’s current Form Item template. Where you can change the colors and layout, for example, we have modified the Vertical Layout of “PART_Label” field as Top in this figure below.</p>
<p><a href="http://akashkava.com/blog/wp-content/uploads/2010/09/ChangeLayout1.png"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="ChangeLayout" border="0" alt="ChangeLayout" src="http://akashkava.com/blog/wp-content/uploads/2010/09/ChangeLayout_thumb1.png" width="644" height="420" /></a></p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fakashkava.com%2Fblog%2F347%2Fhow-to-customize-atomform-label-field-using-expression-blend%2F&amp;title=How%20to%20customize%20AtomForm%20Label%20Field%20using%20Expression%20Blend%3F"><img src="http://akashkava.com/blog/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://akashkava.com/blog/347/how-to-customize-atomform-label-field-using-expression-blend/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>RIA &#8211; Why? Which One? How?</title>
		<link>http://akashkava.com/blog/41/ria-why-which-one-how/</link>
		<comments>http://akashkava.com/blog/41/ria-why-which-one-how/#comments</comments>
		<pubDate>Sat, 13 Dec 2008 17:29:14 +0000</pubDate>
		<dc:creator>Akash Kava</dc:creator>
				<category><![CDATA[RIA]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Client]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[FLEX]]></category>
		<category><![CDATA[Front End]]></category>
		<category><![CDATA[Graphics]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[MIS]]></category>
		<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Sun]]></category>
		<category><![CDATA[Web Service]]></category>
		<category><![CDATA[XUL]]></category>

		<guid isPermaLink="false">http://akashkava.com/blog/?p=41</guid>
		<description><![CDATA[RIA (Rich Internet Application) means faster means to develop light applications to fit in your business presentation and few quick interactive applications. With RIA you can not make a money tree and you can not become rich. Target Applications: Frontend Applications Small Quick Demo Applications Graphical Analysis of MIS Marketing Presentations Quick Forms/Data Entry for [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://akashkava.com/blog/41/ria-why-which-one-how/";
		digg_bgcolor = "";
		digg_skin = "";
		digg_window = "";
		digg_title = "RIA+%26%238211%3B+Why%3F+Which+One%3F+How%3F";
		digg_media = "";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fakashkava.com%2Fblog%2F41%2Fria-why-which-one-how%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fakashkava.com%2Fblog%2F41%2Fria-why-which-one-how%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>RIA (Rich Internet Application) means faster means to develop light applications to fit in your business presentation and few quick interactive applications. With RIA you can not make a money tree and you can not become rich.</p>
<p>Target Applications:</p>
<ol>
<li>Frontend Applications</li>
<li>Small Quick Demo Applications</li>
<li>Graphical Analysis of MIS</li>
<li>Marketing Presentations</li>
<li>Quick Forms/Data Entry for Mass Audience</li>
<li>Polls, Social Interaction Applications</li>
<li>Thin Client Applications</li>
</ol>
<p>With RIA you can generally make a thin client applications, which surely needs to interact with high poerful web server or any other form of server over internet. RIA replaces frontend for modern internet applications from traditional HTML/JS form processing websites.</p>
<h1>WHY RIA?</h1>
<p>Traditional web portal applications (ASP.NET/EJB..) takes too much of time to process every single request, as it does not use full potential of client side computer. Every decision of which button to be displayed, state of an application and user&#8217;s choices and preferences, everything is maintained on server and applications utilizes too much of bandwidth as well.</p>
<p>Thats why, RIA is simple step to differentiate user interface and business logic completely with implementations of standards like SOAP web services and REST apis.</p>
<p>All RIAs are compiled at development site, that means the final RIA is in form of an application, which will execute accurately as designed. However in traditional HTML+JS, if any part of HTML is not rendered properly or its coded wrongly, there is no way to detect until it is delivered to browser and some error has been encountered. Pre compilation on RIA, reduces time required to develop web application drastically.</p>
<h1>WHICH RIA?</h1>
<table style="font-family:Arial, Helvetica, sans-serif; font-size:12px" border="1" cellspacing="0" cellpadding="2" width="620">
<tbody>
<tr>
<th valign="top" scope="col"></th>
<th width="100" align="center" valign="top" scope="col">Flex</th>
<th width="100" align="center" valign="top" scope="col">Silverlight</th>
<th width="100" align="center" valign="top" scope="col">JavaFX</th>
<th width="100" align="center" valign="top" scope="col">XUL</th>
</tr>
<tr>
<td valign="top"><strong>Vendor</strong></td>
<td align="center" valign="top">Adobe</td>
<td align="center" valign="top">Microsoft</td>
<td align="center" valign="top">Sun Microsystems</td>
<td align="center" valign="top">Mozilla</td>
</tr>
<tr>
<td valign="top"><strong>Open Source</strong></td>
<td align="center" valign="top">Yes<br />
(I am talking about FLEX not Flash)</td>
<td align="center" valign="top">No</td>
<td align="center" valign="top">Yes</td>
<td align="center" valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><strong>Support</strong></p>
<p>Community Support is very bad when you need quick solution in an emergency.</td>
<td align="center" valign="top">Paid Support &amp; Community</td>
<td align="center" valign="top">Paid Support &amp; Community</td>
<td align="center" valign="top">Community Support</td>
<td align="center" valign="top">Community Support</td>
</tr>
<tr>
<td valign="top"><strong>Dependency</strong></td>
<td align="center" valign="top">Flash Player</td>
<td align="center" valign="top">Silverlight Player</td>
<td align="center" valign="top">Java Runtime + JavaFX Runtime</td>
<td align="center" valign="top">XUL Runtime</td>
</tr>
<tr>
<td valign="top"><strong>Availability</strong></p>
<p>According to various statistics, the by default availability of dependent software on PCs.</td>
<td align="center" valign="top">95%</td>
<td align="center" valign="top">10%</td>
<td align="center" valign="top">0%</p>
<p>Although few PCs and all MACs have Java Runtime, they still need something additional.</td>
<td align="center" valign="top">30% as FireFox supports XUL Apps</td>
</tr>
<tr>
<td valign="top"><strong>Size of Runtime</strong></td>
<td align="center" valign="top">1MB</td>
<td align="center" valign="top">4.5MB</td>
<td align="center" valign="top">30MB</td>
<td align="center" valign="top">4MB</td>
</tr>
<tr>
<td valign="top"><strong>Native Device Access</strong></td>
<td align="center" valign="top">Camera, Mic and Speakers</td>
<td align="center" valign="top">Speakers</td>
<td align="center" valign="top">Speakers</td>
<td align="center" valign="top">None in Web App,</p>
<p>May be few in Desktop App</td>
</tr>
<tr>
<td valign="top"><strong>Audio Video Support</strong></td>
<td align="center" valign="top">Widely used FLV and MP3 format, stable and its there since 2001</td>
<td align="center" valign="top">WMV/WMA/WMA Pro</td>
<td align="center" valign="top">No</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top"><strong>Converters for the Supported Video</strong></td>
<td align="center" valign="top">FFMPEG and many other commercial vendors available</td>
<td align="center" valign="top">Paid Encoders</td>
<td align="center" valign="top">No</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top"><strong>Documentation</strong></td>
<td align="center" valign="top">SDK Documentation and Samples</td>
<td align="center" valign="top">MSDN but still very premature, (Reason, the learning curve is little higher)</td>
<td align="center" valign="top">JavaDocs but JavaFX is still new</td>
<td align="center" valign="top">Apache Documentation, very scattered, difficult to learn.</td>
</tr>
<tr>
<td valign="top"><strong>Syntax</strong></td>
<td align="center" valign="top">XML + Action Script</td>
<td align="center" valign="top">XML + C# / JS / VB.NET</td>
<td align="center" valign="top">Totally New Syntax</td>
<td align="center" valign="top">XML + JS</td>
</tr>
<tr>
<td valign="top"><strong>Language Feature</strong></td>
<td align="center" valign="top">Strictly Typed with &#8220;Object&#8221; being dynamic type</td>
<td align="center" valign="top">Strictly Typed,</p>
<p>Dynamic type to come in C# 4.0</td>
<td align="center" valign="top">Strictly Typed</td>
<td align="center" valign="top">Dynamic Typed</td>
</tr>
<tr>
<td valign="top"><strong>Binding Expressions</strong></p>
<p>Flex introduced wonderful concept of auto updating expressions when properties or variables changes.</td>
<td align="center" valign="top">Very Accurate</td>
<td align="center" valign="top">Accurate but lengthy code</td>
<td align="center" valign="top">Available</td>
<td align="center" valign="top">Better then JavaFX and Silverlight</td>
</tr>
<tr>
<td valign="top"><strong>Two Way Databinding<br />
</strong></td>
<td align="center" valign="top">Not Available, Coming up in Flex 4</td>
<td align="center" valign="top">Available</td>
<td align="center" valign="top">-</td>
<td align="center" valign="top">Available</td>
</tr>
<tr>
<td valign="top"><strong>Binding Declaration</strong></td>
<td align="center" valign="top">Simple Attribute</td>
<td align="center" valign="top">Extra Code in each bindable property</td>
<td align="center" valign="top">Extra code in each bindable property</td>
<td align="center" valign="top">Simple Attribute</td>
</tr>
<tr>
<td valign="top"><strong>Reflection</strong></td>
<td align="center" valign="top">Available</td>
<td align="center" valign="top">Available</td>
<td align="center" valign="top">Available</td>
<td align="center" valign="top">Available</td>
</tr>
<tr>
<td valign="top"><strong>Code Size</strong></td>
<td align="center" valign="top">Very Concise</td>
<td align="center" valign="top">Even simpler things like validator etc takes 6 lines, too big code size to maintain</td>
<td align="center" valign="top">Size is small, but very disorganized, difficult to read</td>
<td align="center" valign="top">Concise enough</td>
</tr>
<tr>
<td valign="top"><strong>Platform Availability</strong></td>
<td align="center" valign="top">Windows, Mac, Linux</td>
<td align="center" valign="top"><strong>Windows Only</strong></td>
<td align="center" valign="top">Windows, Mac, Linux</td>
<td align="center" valign="top">Windows, Mac, Linux</td>
</tr>
<tr>
<td valign="top"><strong>Stability</strong></td>
<td align="center" valign="top">Very Stable</td>
<td align="center" valign="top">Pre Beta</td>
<td align="center" valign="top">Pre Beta</td>
<td align="center" valign="top">Stable Enough</td>
</tr>
<tr>
<td valign="top"><strong>Control Library</strong></td>
<td align="center" valign="top">Rich set of Controls available, plus lots of free stuff available as well</td>
<td align="center" valign="top">Very basic controls, you have to spend money on other ISVs to get good controls</td>
<td align="center" valign="top">Good set of Controls</td>
<td align="center" valign="top">Almost everything is free, lacks good documentation though</td>
</tr>
<tr>
<td valign="top"><strong>Coders Availability</strong></p>
<p>For project managers, how difficult it will be to find coders who will code.</td>
<td align="center" valign="top">Easily Available as existing Flash, HTML, JS, ActionScript can code.</td>
<td align="center" valign="top">C# and Microsoft Technology programmers can code.</td>
<td align="center" valign="top">Java Programmers can code, but due to new syntax, its still difficult to get hands on it.</td>
<td align="center" valign="top">Very difficult as it requires too extra knowledge of mozilla architecture and various standards, which is not taught anywhere.</td>
</tr>
<tr>
<td valign="top"><strong>Commercial Training</strong></p>
<p><strong> </strong>Starting project is very easy, but ongoing maintanence and meeting deadlines requires excellent knowledge of technology, which you should not rely on community blogs, because time required to search any solution is costly.</td>
<td align="center" valign="top">Excellent</td>
<td align="center" valign="top">Excellent</td>
<td align="center" valign="top">Training available</td>
<td align="center" valign="top">Where?</td>
</tr>
<tr>
<td valign="top"><strong>Threading Support</strong></td>
<td align="center" valign="top">No</td>
<td align="center" valign="top">Limited</td>
<td align="center" valign="top">No</td>
<td align="center" valign="top">Limited</td>
</tr>
<tr>
<td valign="top"><strong>Themes/Skinning</strong></td>
<td align="center" valign="top">Yes</td>
<td align="center" valign="top">Yes, but size of code is very big</td>
<td align="center" valign="top">No</td>
<td align="center" valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><strong>WebService Integration</strong></td>
<td align="center" valign="top">Yes</td>
<td align="center" valign="top">Yes</td>
<td align="center" valign="top">Yes but very frustrating</td>
<td align="center" valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><strong>Upload/Download</strong></td>
<td align="center" valign="top">The Best Feature in Flex</td>
<td align="center" valign="top">Yes</td>
<td align="center" valign="top">Yes</td>
<td align="center" valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><strong>Installable on Desktop</strong></td>
<td align="center" valign="top">Yes</td>
<td align="center" valign="top">No</td>
<td align="center" valign="top">Yes</td>
<td align="center" valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><strong>Database Support</strong> (in desktop app only)</td>
<td align="center" valign="top">Sqlite</td>
<td align="center" valign="top">Not Applicable</td>
<td align="center" valign="top">JavaDB</p>
<p>Too heavy and too slow</td>
<td align="center" valign="top">Sqlite</td>
</tr>
<tr>
<td valign="top"><strong>Auto Update on Desktop App</strong></td>
<td align="center" valign="top">Yes</td>
<td align="center" valign="top">No</td>
<td align="center" valign="top">No</td>
<td align="center" valign="top">Yes</td>
</tr>
<tr>
<td valign="top"><strong>Present Since</strong></td>
<td align="center" valign="top">2001</td>
<td align="center" valign="top">2007</td>
<td align="center" valign="top">2007</td>
<td align="center" valign="top">2001</td>
</tr>
<tr>
<td valign="top"><strong>IDE</strong></p>
<p>Plugins are available under eclipse and netbeans etc type of editor, but problem is they are so premature, they dont support refractoring, analysis, debugging and lots of other facilities.</td>
<td align="center" valign="top">Flex Builder</td>
<td align="center" valign="top">Visual Studio</td>
<td align="center" valign="top">Plugin</td>
<td align="center" valign="top">Plugin</td>
</tr>
<tr>
<td valign="top"><strong>IDE Cost</strong></td>
<td align="center" valign="top"></td>
<td align="center" valign="top"></td>
<td align="center" valign="top"></td>
<td align="center" valign="top"></td>
</tr>
<tr>
<td valign="top"><strong>IDE Refractoring</strong></td>
<td align="center" valign="top">Yes</td>
<td align="center" valign="top">Yes</td>
<td align="center" valign="top">No</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top"><strong>IDE Source Versioning</strong></td>
<td align="center" valign="top">CVS</p>
<p>Good for Multiusers</td>
<td align="center" valign="top">Source Safe (Single Developer only)/ TSS (too costly)</td>
<td align="center" valign="top">Plugin</td>
<td align="center" valign="top">Plugin</td>
</tr>
<tr>
<td valign="top"><strong>Drag and Drop Editor</strong></td>
<td align="center" valign="top">Yes</td>
<td align="center" valign="top">Limited, because to script you need Visual Studio and to design you need Blend (Other paid software)</td>
<td align="center" valign="top">No</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top"><strong>Code Intellisense (Auto Complete)</strong></td>
<td align="center" valign="top">Yes</td>
<td align="center" valign="top">Yes</td>
<td align="center" valign="top"></td>
<td align="center" valign="top"></td>
</tr>
<tr>
<td valign="top"><strong>Project Management</strong></td>
<td align="center" valign="top">Yes</td>
<td align="center" valign="top">Yes</td>
<td align="center" valign="top"></td>
<td align="center" valign="top"></td>
</tr>
<tr>
<td valign="top"><strong>Library</strong> <strong>Management</strong></p>
<p>Creating and importing shared code in the form of libraries.</td>
<td align="center" valign="top">Yes</td>
<td align="center" valign="top">Yes</td>
<td align="center" valign="top"></td>
<td align="center" valign="top"></td>
</tr>
<tr>
<td valign="top"><strong>Component Development</strong></td>
<td align="center" valign="top">Very Simple</td>
<td align="center" valign="top">Quite Complex as it is divided in User/Custom controls categories.</td>
<td align="center" valign="top">Available</td>
<td align="center" valign="top">Simple</td>
</tr>
<tr>
<td valign="top"><strong>The Result<br />
</strong></td>
<td align="center" valign="top">Leader of RIA</td>
<td align="center" valign="top">Flex Follower</td>
<td align="center" valign="top">The Last</td>
<td align="center" valign="top">Linux Love</td>
</tr>
</tbody>
</table>
<h1>Important Note:</h1>
<p>Silverlight claims to be platform independent, but reality is, Microsoft no longer provides any more upgrades of Silverlight version for any other operating system other then Windows. And Linux was already not officially supported by Microsoft.</p>
<h1>Advantages of RIA</h1>
<ol>
<li><strong>Reduce Development time</strong><br />
As compared with traditional web application, since RIAs are pre compiled, errors due to syntax, wrong spellings can be detected earlier at time of desiging.</li>
<li><strong>Load First, Run Throughout</strong><br />
RIAs load entire application (Except XUL) in the beginning, instead of HTML+JS, which loads as things proceed. This means, either application will load completely and work accurately even with slower bandwidth connection, or if some part didnt load, it will straightway display an error. So it works like transaction, either all or nothing. HTML+JS can behave unexpectedly in case of missing components.</li>
<li><strong>Seperate Design and Development Processes<br />
</strong>Flex and Sliverlight offers complete seperation of Development and Designing keeping integration simple, other platforms (earlier web ones) require too much time integrating designs and process.</li>
<li><strong>Utilize Client Computing</strong><br />
Almost every computer has high powerful graphics capabilities, HTML/JS doesnt offer any great benefit over it. RIAs can completely explore native graphics capabilities and you get wide range of user interface functionality.</li>
</ol>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fakashkava.com%2Fblog%2F41%2Fria-why-which-one-how%2F&amp;title=RIA%20%26%238211%3B%20Why%3F%20Which%20One%3F%20How%3F"><img src="http://akashkava.com/blog/wp-content/plugins/add-to-any/share_save_256_24.png" width="256" height="24" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://akashkava.com/blog/41/ria-why-which-one-how/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>

