<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>C#</title>
        <link>http://geekswithblogs.net/RizwanSharp/category/7401.aspx</link>
        <description>C#</description>
        <language>en-US</language>
        <copyright>RizwanSharp</copyright>
        <managingEditor>rizwansharp@hotmail.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>Silverlight 3 Out of Browser Experience (Wow Starts Now)</title>
            <link>http://geekswithblogs.net/RizwanSharp/archive/2009/03/24/silverlight-3-out-of-browser-experience-wow-starts-now.aspx</link>
            <description>&lt;p&gt;The day I read about what’s new in Silverlight 3 on Tim’s &lt;a href="http://timheuer.com/blog/archive/2009/03/18/silverlight-3-whats-new-a-guide.aspx" target="_blank"&gt;Blog&lt;/a&gt;, I got really amazed to know that what amazing features this new version has to offer Sigh…&lt;/p&gt;  &lt;p&gt;Among all the cool features, Silverlight 3 provides developers the ability to enable offline application execution. In other words, a developer can provide a few settings in Application Manifest which will make an application be able to save on user’s computer.&lt;/p&gt;  &lt;p&gt;So lets see how it works.&lt;/p&gt;  &lt;p&gt;Create a Silverlight 3 Application in Visual Studio and open the manifest file “AppManifest.xml” which can be found under Properties folder in Solution explorer.&lt;/p&gt;  &lt;p&gt;Contents of the file look like this:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&amp;lt;Deployment xmlns="&lt;/strong&gt;&lt;a href="http://schemas.microsoft.com/client/2007/deployment&amp;quot;"&gt;&lt;strong&gt;http://schemas.microsoft.com/client/2007/deployment"&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;      &lt;br /&gt;        xmlns:x="&lt;/strong&gt;&lt;a href="http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;"&gt;&lt;strong&gt;http://schemas.microsoft.com/winfx/2006/xaml"&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;&amp;gt;      &lt;br /&gt;    &amp;lt;Deployment.Parts&amp;gt;       &lt;br /&gt;    &amp;lt;/Deployment.Parts&amp;gt; &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;    &amp;lt;!-- Uncomment the markup and update the fields below to make your application offline enabled      &lt;br /&gt;    &amp;lt;Deployment.ApplicationIdentity&amp;gt;       &lt;br /&gt;        &amp;lt;ApplicationIdentity       &lt;br /&gt;            ShortName="Out of Browser Silverlight Application"       &lt;br /&gt;            Title="Window Title of Your Silverlight Application"&amp;gt;       &lt;br /&gt;            &amp;lt;ApplicationIdentity.Blurb&amp;gt;Description of your Silverlight application&amp;lt;/ApplicationIdentity.Blurb&amp;gt;       &lt;br /&gt;        &amp;lt;/ApplicationIdentity&amp;gt;       &lt;br /&gt;    &amp;lt;/Deployment.ApplicationIdentity&amp;gt;       &lt;br /&gt;    --&amp;gt;       &lt;br /&gt;&amp;lt;/Deployment&amp;gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Ok Simply uncomment the &lt;/p&gt;  &lt;p&gt;&amp;lt;Deployment.ApplicationIdentity&amp;gt; &lt;/p&gt;  &lt;p&gt;……………    &lt;br /&gt;&amp;lt;/Deployment.ApplicationIdentity&amp;gt;     &lt;br /&gt;Provide application name in ShortName attribute. Title of application host when this application is running out of the browser. Provide Description in &amp;lt;ApplicationIdentity.Blurb&amp;gt;Description of your Silverlight application&amp;lt;/ApplicationIdentity.Blurb&amp;gt;&lt;/p&gt;  &lt;p&gt;Whoops! Application is ready for out of browser execution.&lt;/p&gt;  &lt;p&gt;Simply run the application:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/RizwanSharp/WindowsLiveWriter/Silverlight3OutofBrowserExperienceWowSta_13F17/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://geekswithblogs.net/images/geekswithblogs_net/RizwanSharp/WindowsLiveWriter/Silverlight3OutofBrowserExperienceWowSta_13F17/image_thumb.png" width="817" height="170" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;In the context menu, you have the “Install” option enabled now. Let’s click the install and see what happens?&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/RizwanSharp/WindowsLiveWriter/Silverlight3OutofBrowserExperienceWowSta_13F17/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://geekswithblogs.net/images/geekswithblogs_net/RizwanSharp/WindowsLiveWriter/Silverlight3OutofBrowserExperienceWowSta_13F17/image_thumb_1.png" width="821" height="294" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Select the Shortcuts locations and Click “OK”. Application is now installed on local machine and can be executed by clicking the created shortcuts.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/RizwanSharp/WindowsLiveWriter/Silverlight3OutofBrowserExperienceWowSta_13F17/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://geekswithblogs.net/images/geekswithblogs_net/RizwanSharp/WindowsLiveWriter/Silverlight3OutofBrowserExperienceWowSta_13F17/image_thumb_2.png" width="126" height="168" /&gt;&lt;/a&gt;  &lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/RizwanSharp/WindowsLiveWriter/Silverlight3OutofBrowserExperienceWowSta_13F17/image_8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://geekswithblogs.net/images/geekswithblogs_net/RizwanSharp/WindowsLiveWriter/Silverlight3OutofBrowserExperienceWowSta_13F17/image_thumb_3.png" width="643" height="345" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;You can optionally use &lt;strong&gt;Detach()&lt;/strong&gt; method of &lt;strong&gt;Application&lt;/strong&gt; class under user click to popup the install screen if application not currently installed.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Application.Current.Detach()&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;    &lt;br /&gt;You can check if application is running out of the browser by checking value &lt;strong&gt;RunningOffline &lt;/strong&gt;property of Application class.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;bool offline = Application.Current.RunningOffline;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;You can also provide a set of icons for your application using:&lt;/p&gt;  &lt;p&gt;&amp;lt;ApplicationIdentity.Icons&amp;gt;    &lt;br /&gt;            &amp;lt;Icon Size="16x16"&amp;gt;AppIcon16.png&amp;lt;/Icon&amp;gt;     &lt;br /&gt;            &amp;lt;Icon Size="32x32"&amp;gt;AppIcon32.png&amp;lt;/Icon&amp;gt;     &lt;br /&gt;            &amp;lt;Icon Size="64x64"&amp;gt;AppIcon64.png&amp;lt;/Icon&amp;gt;     &lt;br /&gt;            &amp;lt;Icon Size="128x128"&amp;gt;AppIcon128.png&amp;lt;/Icon&amp;gt;     &lt;br /&gt;&amp;lt;/ApplicationIdentity.Icons&amp;gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;But make sure to add these images to your project with Build action set to&lt;strong&gt; “Content”.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;That was it :) and here is the&lt;strong&gt; &lt;/strong&gt;&lt;a href="http://cid-2a8ea96556f0165f.skydrive.live.com/self.aspx/Public/SilverlightOOBApplication.zip" target="_blank"&gt;&lt;strong&gt;Source Code&lt;/strong&gt;&lt;/a&gt; of Sample Application.&lt;/p&gt;  &lt;p&gt;Happy Silverlighting :D.&lt;/p&gt;  &lt;p&gt;Rizwan a.k.a RizwanSharp&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130368"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130368" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/RizwanSharp/aggbug/130368.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>RizwanSharp</dc:creator>
            <guid>http://geekswithblogs.net/RizwanSharp/archive/2009/03/24/silverlight-3-out-of-browser-experience-wow-starts-now.aspx</guid>
            <pubDate>Wed, 25 Mar 2009 04:26:45 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/RizwanSharp/comments/130368.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/RizwanSharp/archive/2009/03/24/silverlight-3-out-of-browser-experience-wow-starts-now.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/RizwanSharp/comments/commentRss/130368.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/RizwanSharp/services/trackbacks/130368.aspx</trackback:ping>
        </item>
        <item>
            <title>Microsoft MVP Award 2008</title>
            <link>http://geekswithblogs.net/RizwanSharp/archive/2008/04/02/microsoft-mvp-award-2008-again.aspx</link>
            <description>&lt;p&gt;Yes, I have been awarded Microsoft MVP Award once again for my contributions in C# community. It is second time that I'm getting this award. Last time, I got it for the same C#.&lt;/p&gt;
&lt;p&gt;I came to know about this last (4/1/2008) evening No! it was not an April Fool &lt;img alt="" src="/Providers/BlogEntryEditor/FCKeditor/editor/images/smiley/msn/tounge_smile.gif" /&gt; trust me it was as real as it was last year &lt;img alt="" src="/Providers/BlogEntryEditor/FCKeditor/editor/images/smiley/msn/teeth_smile.gif" /&gt;. I thank everyone who supported me in doing this, thank God to give me courage to have more time working for knowledge sharing and learning, my fiancee who always loved and appreciated what I've been doing, my parents who pray a lot for me, Microsoft, Charlie Calvert (C# Community PM) and ofcourse the people who asked questions on forums &lt;img alt="" src="/Providers/BlogEntryEditor/FCKeditor/editor/images/smiley/msn/teeth_smile.gif" /&gt;.&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;Rizwan a.k.a RizwanSharp&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=120958"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=120958" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/RizwanSharp/aggbug/120958.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>RizwanSharp</dc:creator>
            <guid>http://geekswithblogs.net/RizwanSharp/archive/2008/04/02/microsoft-mvp-award-2008-again.aspx</guid>
            <pubDate>Thu, 03 Apr 2008 01:46:13 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/RizwanSharp/comments/120958.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/RizwanSharp/archive/2008/04/02/microsoft-mvp-award-2008-again.aspx#feedback</comments>
            <slash:comments>7</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/RizwanSharp/comments/commentRss/120958.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/RizwanSharp/services/trackbacks/120958.aspx</trackback:ping>
        </item>
        <item>
            <title>Deep Dive into XAML (Part 2 of WPF Learning Series)</title>
            <link>http://geekswithblogs.net/RizwanSharp/archive/2007/12/31/deep-dive-into-xaml-part-2-of-wpf-learning-series.aspx</link>
            <description>&lt;style type="text/css"&gt;&lt;![CDATA[

 p.msonormal1
	{margin-top:0in;
	margin-right:0in;
	margin-bottom:10.0pt;
	margin-left:0in;
	line-height:115%;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";
	}
p.msolistparagraph
	{margin: 5.2pt 0in;
	font-size:12.0pt;
		font-family:"Times New Roman","serif";
	}]]&gt;&lt;/style&gt;
&lt;p style="line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;In &lt;a href="http://geekswithblogs.net/RizwanSharp/archive/2007/12/16/an-introduction-to-wpf-part-1-of-wpf-learning-series.aspx"&gt;&lt;span style="color: rgb(102, 153, 102);"&gt;last article&lt;/span&gt;&lt;/a&gt; we talked about WPF as a next generation UX development technology from Microsoft. We also talked about declarative programming model it provides through the use of new XML based declarative language “XAML (a.k.a Zammel)”. In this article we’ll be digging deeper in XAML by understanding its usefulness in application development and its principles by writing snippets of code.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;&lt;span style=""&gt; &lt;/span&gt;If someone is not sure of what declarative programming model is, I suggest reading &lt;a href="http://en.wikipedia.org/wiki/Declarative_programming"&gt;&lt;span style="color: rgb(102, 153, 102);"&gt;this&lt;/span&gt;&lt;/a&gt; or searching on web because this is not the part of our discussion today so I encourage you to explore it yourself.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 12pt;"&gt;What is XAML?&lt;/span&gt;&lt;/strong&gt;&lt;strong style=""&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;XAML (a.k.a Zammel) is a simple and general purpose XML based declarative language for declaring hierarchy of .Net objects which are instantiated at runtime. General purpose? Yes! It is very important to understand that XAML does not have ties to WPF and both of these can be used independently. Not to be mentioned that the use of XAML is optional when working with WPF and XAML can actually be used in other .Net technologies as well. Anything that can be done with XAML can also be done with the code of your favorite .Net language such as VB or C#.&lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;Before you loose your interest in XAML due to the above explanation and before we proceed further in learning XAML, it is important to understand why XAML is important and why it should be used for laying out UI stuff in WPF applications.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 12pt;"&gt;Why use XAML?&lt;/span&gt;&lt;/strong&gt;&lt;strong style=""&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="margin-left: 0.5in; text-indent: -0.25in;" class="MsoListParagraph"&gt;&lt;span style="font-size: 13.5pt; font-family: symbol;"&gt;&lt;span style=""&gt;·&lt;span times="" roman="" new=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-bidi-font-size: 12.0pt" style="font-size: 10pt;"&gt;Separation of Design from Code&lt;/span&gt;&lt;/strong&gt;&lt;span trebuchet="" ms="," sans-serif="" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in 5.2pt 0.5in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;It is a good design principal to separate the UI design from the code for maintainability reasons and fortunately XAML encourages it by default. (UI stuff done in XAML and business logic in code behind) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 0.5in; text-indent: -0.25in;" class="MsoListParagraph"&gt;&lt;span style="font-size: 13.5pt; font-family: symbol;"&gt;&lt;span style=""&gt;·&lt;span times="" roman="" new=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-bidi-font-size: 12.0pt" style="font-size: 10pt;"&gt;Designer/Developer Collaboration&lt;/span&gt;&lt;/strong&gt;&lt;span trebuchet="" ms="," sans-serif="" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in 5.2pt 38.6pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;Most developers don’t know the use of design tools such as Expression Blend, Expression Design, Adobe Illustrator etc. Same is true for designers who don’t know C#, VB or other programming languages. So you can say there was no way before WPF or specifically XAML for a software development team to effectively work together on a software project. But now with XAML it is possible that designers create a software prototype in their favorite design tool and export XAML which can be used by developers in further development or the reverse is also true.&lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 0.5in; text-indent: -0.25in;" class="MsoListParagraph"&gt;&lt;span style="font-size: 13.5pt; font-family: symbol;"&gt;&lt;span style=""&gt;·&lt;span times="" roman="" new=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-bidi-font-size: 12.0pt" style="font-size: 10pt;"&gt;Easy to be Parsed, Serialized and Desterilized&lt;/span&gt;&lt;/strong&gt;&lt;span trebuchet="" ms="," sans-serif="" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in 5.2pt 38.6pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;XAML is xml based which makes it very easy to parse, serialized and desterilized XAML for dynamic UI scenarios whereas parsing C# or VB code and serializing/desterilizing it is a superb headache where only compiler designers may succeed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 0.5in; text-indent: -0.25in;" class="MsoListParagraph"&gt;&lt;span style="font-size: 13.5pt; font-family: symbol;"&gt;&lt;span style=""&gt;·&lt;span times="" roman="" new=""&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-bidi-font-size: 12.0pt" style="font-size: 10pt;"&gt;Simplicity &lt;/span&gt;&lt;/strong&gt;&lt;span trebuchet="" ms="," sans-serif="" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in 5.2pt 38.6pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;XAML is a simple language which has really short learning curve as compare to any other programming language. So it is very easy for a designer/web developer (those are already familiar with HTML) to learn it. After reading and understanding this article you’ll be in condition to validate this point.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 0.5in; text-indent: -0.25in;" class="MsoListParagraph"&gt;&lt;span style="font-size: 10pt; font-family: symbol;"&gt;&lt;span style=""&gt;·&lt;span times="" roman="" new=""&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-bidi-font-size: 12.0pt" style="font-size: 10pt;"&gt;Shorter Code &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in 5.2pt 38.6pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;In most scenarios XAML code is shorter (due to shortcuts provided in it) than the code in any other language for the same output.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;To conclude the discussion of the importance of XAML in WPF we can say that though XAML is not necessary for WPF but it opens doors to a whole new world for designer/developer collaboration where they can produce a stunning output using the same underlying technology but different set of tools which interface with that differently.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;At this point, I understand that you are convinced to learn XAML so let’s get started&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: wingdings;"&gt;&lt;span style=""&gt;J&lt;/span&gt;&lt;/span&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 12pt;"&gt;Basics of XAML&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;As I mentioned previously that XAML is very easy to learn and work with if you really understand its rules which are as follow:&lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 0.5in; text-indent: -0.25in;" class="MsoListParagraph"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: Arial" style="font-size: 10pt;"&gt;&lt;span style=""&gt;1.&lt;span times="" roman="" new=""&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span arial="," sans-serif="" style="font-size: 10pt;"&gt;XAML is case Sensitive like XML and C#.&lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 0.5in; text-indent: -0.25in;" class="MsoListParagraph"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: Arial" style="font-size: 10pt;"&gt;&lt;span style=""&gt;2.&lt;span times="" roman="" new=""&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span arial="," sans-serif="" style="font-size: 10pt;"&gt;Each XAML document can have only one root element.&lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 0.5in; text-indent: -0.25in;" class="MsoListParagraph"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: Arial" style="font-size: 10pt;"&gt;&lt;span style=""&gt;3.&lt;span times="" roman="" new=""&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span arial="," sans-serif="" style="font-size: 10pt;"&gt;Each element in XAML usually represents an object of .Net class of same name. E.g. if there is a &amp;lt;Button /&amp;gt; element, it instruct WPF to create a Button object at runtime using its default constructor. (However, sometimes elements are also used to set properties which are not otherwise expressible. We’ll be looking at this shortly in this article).&lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 0.5in; text-indent: -0.25in;" class="MsoListParagraph"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: Arial" style="font-size: 10pt;"&gt;&lt;span style=""&gt;4.&lt;span times="" roman="" new=""&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span arial="," sans-serif="" style="font-size: 10pt;"&gt;On each element you can set one or more properties through attributes as we do in XML. But as mentioned previously some properties cannot be expressed through attribute syntax so we have to apply property element syntax i.e use of elements to set properties. For setting such properties we use a special syntax which makes them different from object elements.&lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 0.5in; text-indent: -0.25in;" class="MsoListParagraph"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: Arial" style="font-size: 10pt;"&gt;&lt;span style=""&gt;5.&lt;span times="" roman="" new=""&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span arial="," sans-serif="" style="font-size: 10pt;"&gt;On each element you can attach one or more event handlers using the same attribute syntax as used to set properties.&lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left: 0.5in;" class="MsoListParagraph"&gt;&lt;span trebuchet="" ms="," sans-serif="" style="font-size: 13.5pt;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 12pt;"&gt;Initializing Object (Object Elements) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;In XML, there is a concept of elements. Since XAML is an XML based language, same applies to XAML too. But to understand what elements in XAML mean to XAML compiler/runtime parser, let’s look at the following simple XAML code snippet: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 10pt;"&gt;XAML Code &lt;/span&gt;&lt;/strong&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Button&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt; xmlns&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation" /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 10pt;"&gt;Equivalent C# Code &lt;/span&gt;&lt;/strong&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;System.Windows.Controls.&lt;span style="color: rgb(43, 145, 175);"&gt;Button&lt;/span&gt; button = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Button&lt;/span&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;Both XAML and C# code are equivalent but you can test XAML’s output without compilation in XamlPad which is a tool that comes with Windows SDK V.6 and is installed by Visual Studio 2008 (code named “Orcas”). You can find this tool in &amp;lt;Programs Files&amp;gt;\Microsoft SDKs\Windows\v6.0A\Bin\. Simply open up XamlPad by running the exe and paste the above given XAML snippet in the tool and you should immediately see the output. &lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;You can also save XAML code snippet in a file with .xaml extension and open it in web browser such as Internet Explorer or Mozilla FireFox to view the output. &lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;Above given XAML code snippet when pasted in XamlPad produces the following output:&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;&lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/RizwanSharp/WindowsLiveWriter/DeepDiveintoXAMLPart2ofWPFLearningSeries_14FEC/image_8.png"&gt;&lt;img height="330" width="542" border="0" src="http://geekswithblogs.net/images/geekswithblogs_net/RizwanSharp/WindowsLiveWriter/DeepDiveintoXAMLPart2ofWPFLearningSeries_14FEC/image_thumb_3.png" alt="image" style="border-width: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p align="center" style="margin: 5.2pt 0in; line-height: normal; text-align: center;" class="MsoNormal1"&gt;&lt;a href="file:///C:/Users/RizwanSharp/AppData/Roaming/Windows%20Live%20Writer/PostSupportingFiles/a746ae0d-7744-46fc-b3e9-3505cd19da59/image4.png"&gt;&lt;span arial="," sans-serif="; TEXT-DECORATION: none; mso-fareast-font-family: 'Times New Roman'; text-underline: none; mso-no-proof: yes" style="font-size: 13.5pt; color: rgb(102, 153, 102);"&gt;&lt;v:shapetype stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600" id="_x0000_t75"&gt;&lt;v:stroke joinstyle="miter"&gt;&lt;/v:stroke&gt;&lt;v:formulas&gt;&lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @0 1 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum 0 0 @1"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @2 1 2"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @3 21600 pixelWidth"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @3 21600 pixelHeight"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @0 0 1"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @6 1 2"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @7 21600 pixelWidth"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @8 21600 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @7 21600 pixelHeight"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @10 21600 0"&gt;&lt;/v:f&gt;&lt;/v:formulas&gt;&lt;v:path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"&gt;&lt;/v:path&gt;&lt;o:lock aspectratio="t" v:ext="edit"&gt;&lt;/o:lock&gt;&lt;/v:shapetype&gt;&lt;v:shape alt="image" type="#_x0000_t75" o:spid="_x0000_i1027" o:button="t" href="file:///C:\Users\RizwanSharp\AppData\Roaming\Windows%20Live%20Writer\PostSupportingFiles\a746ae0d-7744-46fc-b3e9-3505cd19da59\image4.png" style="visibility: visible; width: 348pt; height: 210pt;" id="Picture_x0020_1"&gt;&lt;v:imagedata o:title="image" src="file:///C:\Users\RIZWAN~1\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png"&gt;&lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/span&gt;&lt;/a&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;Note that XamlPad is just a handy tool to test if XAML is valid and what it produces. Also there is no intellisense support in XamlPad but visual studio 2008 provides complete intellisense support for XAML. &lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;Let’s get back our discussion in understanding role of elements in objection initialization in XAML. &lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;Declaring an XML element in XAML is equivalent to instantiating the .Net object of same name with default (parameter-less) constructor. Such element is called object element. &lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;You can also see an xml namespace declaration in previous XAML snippet but please forget about that for a little bit time and just assume that it must have to exist at the top level object element in your XAML file otherwise it will not work. &lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;So conclusion is that initializing an object in XAML is as easy as writing an XML element whose name must be the same as off the corresponding .Net object you want to initialize. &lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;It’s pretty neat and straightforward, isn’t it? I know your answer is yes of course. So let’s go ahead&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: wingdings;"&gt;&lt;span style=""&gt;J&lt;/span&gt;&lt;/span&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 12pt;"&gt;Setting Simple Properties (Property Attributes) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;In previous example we learned that how to declare an object in XAML which will be created at runtime by WPF using its default constructor. And now we have to see that how to set properties of same object in XAML. Have a look at the following code snippet: &lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 10pt;"&gt;XAML Code &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Button&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt; xmlns&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;&lt;span style=""&gt;           &lt;/span&gt;&lt;span style="color: red;"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;strong style=""&gt;Content&lt;/strong&gt;&lt;/span&gt;&lt;strong style=""&gt;&lt;span style="color: blue;"&gt;="Hello XAML"&lt;/span&gt;&lt;span style="color: red;"&gt; Width&lt;/span&gt;&lt;span style="color: blue;"&gt;="200"&lt;/span&gt;&lt;span style="color: red;"&gt; Height&lt;/span&gt;&lt;span style="color: blue;"&gt;="24"&lt;/span&gt;&lt;/strong&gt;&lt;span style="color: blue;"&gt; /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 10pt;"&gt;Equivalent C# Code &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(43, 145, 175);"&gt;Button&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt; button = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Button&lt;/span&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;button.Width = 220;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormalCxSpMiddle"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;button.Height = 24;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormalCxSpMiddle"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;button.Content = &lt;span style="color: rgb(163, 21, 21);"&gt;"Hello XAML"&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;Above given XAML code snippet when pasted in XamlPad produces the following output:&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;&lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/RizwanSharp/WindowsLiveWriter/DeepDiveintoXAMLPart2ofWPFLearningSeries_14FEC/image_10.png"&gt;&lt;img height="339" width="565" border="0" src="http://geekswithblogs.net/images/geekswithblogs_net/RizwanSharp/WindowsLiveWriter/DeepDiveintoXAMLPart2ofWPFLearningSeries_14FEC/image_thumb_4.png" alt="image" style="border-width: 0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p align="center" style="margin: 5.2pt 0in; line-height: normal; text-align: center;" class="MsoNormal1"&gt;&lt;a href="file:///C:/Users/RizwanSharp/AppData/Roaming/Windows%20Live%20Writer/PostSupportingFiles/a746ae0d-7744-46fc-b3e9-3505cd19da59/image12.png"&gt;&lt;span arial="," sans-serif="; TEXT-DECORATION: none; mso-fareast-font-family: 'Times New Roman'; text-underline: none; mso-no-proof: yes" style="font-size: 10pt; color: rgb(102, 153, 102);"&gt;&lt;v:shape alt="image" type="#_x0000_t75" o:spid="_x0000_i1026" o:button="t" href="file:///C:\Users\RizwanSharp\AppData\Roaming\Windows%20Live%20Writer\PostSupportingFiles\a746ae0d-7744-46fc-b3e9-3505cd19da59\image12.png" style="visibility: visible; width: 353.25pt; height: 210.75pt;" id="Picture_x0020_2"&gt;&lt;v:imagedata o:title="image" src="file:///C:\Users\RIZWAN~1\AppData\Local\Temp\msohtmlclip1\01\clip_image003.png"&gt;&lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/span&gt;&lt;/a&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;Each attribute inside an object element represents either property or an event. (We’ll be looking at events shortly. But a thing to note is that you cannot distinguish between attributes which represent events and which represent properties unless you know them by name or use see the event or property symbols in Visual Studio’s Intellisense) &lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;An important concept to understand here is that how a string representation of some value in XAML can be assigned to some property is not of type string. For example in above example Width="200". Here comes the role of TypeConvertors which do the dirty work for you. WPF includes type convertors for many .Net types and all are inherited from TypeConvertor base class. &lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;Also, have you visualize the difference between size of XAML code and its corresponding C# code. I have already mentioned that in most cases XAML is shorter to type than some procedural code and Visual Studio even makes it fun to do with its rich intellisense support.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 12pt;"&gt;Setting Complex Properties (Property Elements)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;We have just seen that how to use attributes to set properties in XAML but in many situations it is not possible to set properties using attribute syntax in XAML because you cannot express the it complexity using a simple string as we did in last example to set three different properties. &lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;Let’s consider you need to set an image in button’s content property instead of plain text how you’ll set another button to button’s content property using property attribute syntax? Answer to this question is Property Elements. Yes, as I already mentioned that elements in XAML can also represent properties but they have special syntax so it’s indeed very easy to distinguish them from object elements. Let’ see XAML. &lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 10pt;"&gt;XAML Code&lt;/span&gt;&lt;/strong&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Button&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt; xmlns&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; text-indent: 0.5in; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;/strong&gt;&lt;strong style=""&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Button.Content&lt;/span&gt;&lt;/strong&gt;&lt;strong style=""&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Button&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt; Width&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;="100"&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt; Height&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;="24"&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt; Content&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;="Inner Button" /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; text-indent: 0.5in; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;/strong&gt;&lt;strong style=""&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Button.Content&lt;/span&gt;&lt;/strong&gt;&lt;strong style=""&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Button&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 10pt;"&gt;Equivalent C# Code &lt;/span&gt;&lt;/strong&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(43, 145, 175);"&gt;Button&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt; outerButton = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Button&lt;/span&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(43, 145, 175);"&gt;Button&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt; innerButton = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Button&lt;/span&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;innerButton.Width = 100;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormalCxSpMiddle"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;innerButton.Height = 24;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormalCxSpMiddle"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;outerButton.Content = innerButton;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;Above given XAML code snippet when pasted in XamlPad produces the following output:&lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p align="center" style="margin: 5.2pt 0in; line-height: normal; text-align: center;" class="MsoNormal1"&gt;&lt;a href="file:///C:/Users/RizwanSharp/AppData/Roaming/Windows%20Live%20Writer/PostSupportingFiles/a746ae0d-7744-46fc-b3e9-3505cd19da59/image17.png"&gt;&lt;span arial="," sans-serif="; TEXT-DECORATION: none; mso-fareast-font-family: 'Times New Roman'; text-underline: none; mso-no-proof: yes" style="font-size: 10pt; color: rgb(102, 153, 102);"&gt;&lt;v:shape alt="image" type="#_x0000_t75" o:spid="_x0000_i1025" o:button="t" href="file:///C:\Users\RizwanSharp\AppData\Roaming\Windows%20Live%20Writer\PostSupportingFiles\a746ae0d-7744-46fc-b3e9-3505cd19da59\image17.png" style="visibility: visible; width: 370.5pt; height: 220.5pt;" id="Picture_x0020_3"&gt;&lt;v:imagedata o:title="image" src="file:///C:\Users\RIZWAN~1\AppData\Local\Temp\msohtmlclip1\01\clip_image005.png"&gt;&lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/span&gt;&lt;/a&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/RizwanSharp/WindowsLiveWriter/DeepDiveintoXAMLPart2ofWPFLearningSeries_14FEC/image_12.png"&gt;&lt;img height="361" width="601" border="0" src="http://geekswithblogs.net/images/geekswithblogs_net/RizwanSharp/WindowsLiveWriter/DeepDiveintoXAMLPart2ofWPFLearningSeries_14FEC/image_thumb_5.png" alt="image" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;Does this make sense to put button in button? I know you are thinking “NO” and that’s what I agree upon but I just wanted to remind one of the features of WPF I talked about in my last article i.e. “Customization and composition WPF provides where you can almost put anything in any other thing. You can even put a 3D animation, a listbox or any other control inside a button or any other item. So everything in WPF behaves like a container (parent control).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 12pt;"&gt;Attaching Event Handlers (Event Attributes) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;Attaching events in XAML is as simple as setting property with property attribute syntax which is the simplest way to set simple properties. &lt;/span&gt;&lt;span serif="; mso-fareast-font-family: 'Times New Roman'" times="" roman="," new="" style="font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;Consider this: &lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 10pt;"&gt;XAML Code &lt;/span&gt;&lt;/strong&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Button&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt; xmlns&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;&lt;span style=""&gt;           &lt;/span&gt;&lt;span style="color: red;"&gt;&lt;span style=""&gt; &lt;/span&gt;Content&lt;/span&gt;&lt;span style="color: blue;"&gt;="Hello XAML"&lt;/span&gt;&lt;span style="color: red;"&gt; &lt;strong style=""&gt;Click&lt;/strong&gt;&lt;/span&gt;&lt;strong style=""&gt;&lt;span style="color: blue;"&gt;="Button_Click"&lt;/span&gt;&lt;/strong&gt;&lt;span style="color: blue;"&gt; /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 10pt;"&gt;Equivalent C# Code &lt;/span&gt;&lt;/strong&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;System.Windows.Controls.&lt;span style="color: rgb(43, 145, 175);"&gt;Button&lt;/span&gt; button = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Button&lt;/span&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormalCxSpMiddle"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;button.Content = &lt;span style="color: rgb(163, 21, 21);"&gt;"Hello XAML"&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormalCxSpMiddle"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;button.Click += &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;RoutedEventHandler&lt;/span&gt;(button_Click);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;The above example sets both property and event attributes through the same syntax. But this code is referencing some function to handle the click event; this code cannot be viewed in XamlPad because there is not code behind file with that function. Anyway, you can fire up Visual Studio and experiment it in there without any problem. &lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;I think you have just had a sigh &lt;/span&gt;&lt;em style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 10pt;"&gt;“Ahhh”&lt;/span&gt;&lt;/em&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt; XAML is based on extremely simple rules. Now you are familiar with what elements and attributes of XML mean in XAMl, Let’s move further. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 12pt;"&gt;Namespaces &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;In previous all XAML code snippets you noticed an XML attribute which seems to be a property set with property attribute syntax but it is not. It is XML namespace to be used to find the objects in WPF assemblies. This string is hard-coded in all WPF assemblies with several instance of XmlnsDefinitionAttribute custom attribute. This is needed because XAML cannot only be dependent on element name to use to initialize object because more than one namespaces can have classes with same name. One other thing is that mapping between .Net namespace and XML namespace is not one-to-one but several .Net namespaces have same XML namespace so that XAML should remain as simple as possible. &lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;The root object element of each XAML file must contain at least one XML namespace to qualify itself and its children. Each child can have its own XML namespace in it object element but it’ll make XAML look messy. If there is need to define more than one namespaces then each additional namespace should be given a unique prefix. &lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;The good design principal is that most basic and most used namespace should be prefix free and all additional namespaces should have a small prefix. &lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;Let’s create a new WPF application in Visual Studio 2008, Visual Studio will create a Window1.xaml file with Window1.xaml.cs file for you as main window. We’ll be discussing about Window1.xaml.cs (Code behind shortly). &lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Window&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt; x&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;:&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt;Class&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;="WpfLsArticle2.Window1"&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;span style="color: red;"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;strong style=""&gt;xmlns&lt;/strong&gt;&lt;/span&gt;&lt;strong style=""&gt;&lt;span style="color: blue;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;span style="color: red;"&gt;&lt;span style=""&gt; &lt;/span&gt;xmlns&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: red;"&gt;x&lt;/span&gt;&lt;span style="color: blue;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;span style="color: red;"&gt;&lt;span style=""&gt; &lt;/span&gt;Title&lt;/span&gt;&lt;span style="color: blue;"&gt;="Window1"&lt;/span&gt;&lt;span style="color: red;"&gt; Height&lt;/span&gt;&lt;span style="color: blue;"&gt;="285"&lt;/span&gt;&lt;span style="color: red;"&gt; Width&lt;/span&gt;&lt;span style="color: blue;"&gt;="314"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Grid&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Grid&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Window&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;In above XAML code snippet, we can see two XAML namespaces. First is prefix free so it becomes the default namespace of entire XAML document while the second one has been prefixed with an x and it can be referred by any element with the same prefix. We have two UI elements (Window and Grid) in the above XAML document and both are prefix free so it means XAML parser locates them in all .Net namespaces which are mapped to xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation.&lt;/span&gt;&lt;span serif="; mso-fareast-font-family: 'Times New Roman'" times="" roman="," new="" style="font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;But if we want to use something from the second namespace we would do it this way:&lt;/span&gt;&lt;span serif="; mso-fareast-font-family: 'Times New Roman'" times="" roman="," new="" style="font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Window&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt; &lt;strong style=""&gt;x&lt;/strong&gt;&lt;/span&gt;&lt;strong style=""&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;:&lt;/span&gt;&lt;/strong&gt;&lt;strong style=""&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt;Class&lt;/span&gt;&lt;/strong&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;="WpfLsArticle2.Window1"&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;span style="color: red;"&gt;&lt;span style=""&gt; &lt;/span&gt;xmlns&lt;/span&gt;&lt;span style="color: blue;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;span style="color: red;"&gt;&lt;span style=""&gt; &lt;/span&gt;xmlns&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: red;"&gt;x&lt;/span&gt;&lt;span style="color: blue;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;span style="color: red;"&gt;&lt;span style=""&gt; &lt;/span&gt;Title&lt;/span&gt;&lt;span style="color: blue;"&gt;="Window1"&lt;/span&gt;&lt;span style="color: red;"&gt; Height&lt;/span&gt;&lt;span style="color: blue;"&gt;="285"&lt;/span&gt;&lt;span style="color: red;"&gt; Width&lt;/span&gt;&lt;span style="color: blue;"&gt;="314"&lt;/span&gt;&lt;span style="color: red;"&gt; &lt;strong style=""&gt;x&lt;/strong&gt;&lt;/span&gt;&lt;strong style=""&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: red;"&gt;Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="window1"&lt;/span&gt;&lt;/strong&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Grid&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt; &lt;strong style=""&gt;x&lt;/strong&gt;&lt;/span&gt;&lt;strong style=""&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;:&lt;/span&gt;&lt;/strong&gt;&lt;strong style=""&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt;Name&lt;/span&gt;&lt;/strong&gt;&lt;strong style=""&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;="mainGrid"&lt;/span&gt;&lt;/strong&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Grid&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Window&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormalCxSpMiddle"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;In WPF it is not important to name every UI element, we can name only those items which we want to access and manipulate programmatically from the code behind this keeps XAML simplified with elimination of unnecessary attributes. There are two ways to set name of an element; one is to use its Name property but you may agree that not all classes expose Name property specially non UI classes we can still set name on such elements using XAML namespace (prefixed with an x) x:Name and the result remains the same. For consistency I personally prefer to use x:Name syntax. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 12pt;"&gt;Another Way to Set Properties (Markup Extensions) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;We have already seen two ways (property attribute and property elements) to set properties on objects in XAML but it is not desirable to hard-code the property value. Or at some time, you may need to set a property’s value to an object that already exists somewhere in your application or you may need to bind it to some other control’s property and so on. In this situation you can only get your work done with Markup Extension which is another way to set properties in XAML. Markup Extension extends the previously described property attribute and property element syntaxes to set properties. &lt;/span&gt;&lt;span serif="; mso-fareast-font-family: 'Times New Roman'" times="" roman="," new="" style="font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 10pt;"&gt;XAML Code&lt;/span&gt;&lt;/strong&gt;&lt;span serif="; mso-fareast-font-family: 'Times New Roman'" times="" roman="," new="" style="font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Button&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt; xmlns&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color: red;"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: red;"&gt;x&lt;/span&gt;&lt;span style="color: blue;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormalCxSpMiddle"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style="color: red;"&gt;Foreground&lt;/span&gt;&lt;span style="color: blue;"&gt;="{&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;x&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;Static&lt;/span&gt;&lt;span style="color: red;"&gt; SystemColors&lt;/span&gt;&lt;span style="color: blue;"&gt;.&lt;/span&gt;&lt;span style="color: red;"&gt;ActiveCaptionBrush&lt;/span&gt;&lt;span style="color: blue;"&gt;}"&lt;/span&gt;&lt;span style="color: red;"&gt; &lt;span style=""&gt;                    &lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;Content&lt;/span&gt;&lt;span style="color: blue;"&gt;="Hello"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormalCxSpMiddle"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Button&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 10pt;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 10pt;"&gt;Equivalent C# Code &lt;/span&gt;&lt;/strong&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormalCxSpMiddle"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(43, 145, 175);"&gt;Button&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt; button = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Button&lt;/span&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormalCxSpMiddle"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;button.Foreground = &lt;span style="color: rgb(43, 145, 175);"&gt;SystemColors&lt;/span&gt;.ActiveCaptionBrush;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormalCxSpMiddle"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;button.Content = &lt;span style="color: rgb(163, 21, 21);"&gt;"Hello"&lt;/span&gt;;&lt;/span&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt; &lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormalCxSpMiddle"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;Markup extensions are written with curly brackes which enlose a string which evaluates to some value or object at runtime. Static identifier in the above example is the name of the markup extension class in XAML namespace prefixed with x. Such classes usually have Extension suffix with them such as StaticExtesion or NullExtension but in XAML, this prefix can be omitted. Markup extensions are very useful because they are used for data binding.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormalCxSpMiddle"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 12pt;"&gt;Code Behind Files &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;Of course XAML provides us a convenient way to define application’s UI elements in a hierarchal fashion and also helps us to integrate the other part of the world i.e. designers in application development process but application has no value without code which has your business logic and logic to manipulate the UI done in XAML. In other words, to build a true application both XAML and procedural code have to work together so let’s see how it works…&lt;/span&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 10pt;"&gt; &lt;/span&gt;&lt;/strong&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt;x&lt;/span&gt;&lt;/strong&gt;&lt;strong style=""&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;:&lt;/span&gt;&lt;/strong&gt;&lt;strong style=""&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt;Class&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;="WpfLsArticle2.Window1"&lt;/span&gt;&lt;/strong&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt; &lt;/span&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;on Window object element&lt;/span&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 10pt;"&gt; &lt;/span&gt;&lt;/strong&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;in the previous XAML document, links the two worlds together where the code behind file generated by Visual Studio looks like: &lt;/span&gt;&lt;span serif="; mso-fareast-font-family: 'Times New Roman'" times="" roman="," new="" style="font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;public&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;partial&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Window1&lt;/span&gt; : &lt;span style="color: rgb(43, 145, 175);"&gt;Window&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; text-indent: 0.5in; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;public&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt; Window1()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;&lt;span style=""&gt;      &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style=""&gt;      &lt;/span&gt;InitializeComponent();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;&lt;span style=""&gt;      &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormalCxSpMiddle"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;}&lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormalCxSpMiddle"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;In this code behind file you can provide your event handling code.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormalCxSpMiddle"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 5.2pt; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 12pt;"&gt;XAML Compilation &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 5.2pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;A typical WPF application (with both XAML and Procedural Code) gets compiled and converted in to an assembly (.exe or .dll) in two phase process. In first phase of compilation of a WPF application, all XAML files get compiled into Binary Application Markup Language (BAML) by XAML compiler (xamlc.exe). For example, if your application has a XAML file MainWindow.xaml with its code behind in MainWindow.xaml.cs, during XAML compilation process MainWindow.xaml would get compiled into MainWindow.baml and then placed temporarily in obj\Debug or obj\Release (depending on debug or release build mode respectively). At the same time during the first phase of compilation process, a partial class would also be generated MainWindow.g.cs and placed with the BAML file (in obj\Debug or obj\Release) generated previously. This generated partial class includes code for all the fields of objects declared in window, code to load BAML, code which connects each control to its corresponding generate field and code which attached event handlers. &lt;/span&gt;&lt;span serif="; mso-fareast-font-family: 'Times New Roman'" times="" roman="," new="" style="font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;In the second phase of compilation your own partial class portion is compiled with the partial class portion generated by previous phase by your language compiler such as csc.exe in case of C#. Compiled code then becomes a single assembly and BAML files are embedded as a resource in that assembly. &lt;/span&gt;&lt;span serif="; mso-fareast-font-family: 'Times New Roman'" times="" roman="," new="" style="font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormalCxSpMiddle"&gt;&lt;em style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 10pt;"&gt;“BAML is nothing but a compact, tokenized and fast to load representation of XAML” &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormalCxSpMiddle"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 5.2pt; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 12pt;"&gt;Loading and Parsing XAML at Runtime &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 5.2pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;The coolest part of the story is that you can build or customize UI of your application on the fly by loading XAML from database or somewhere from the internet. This can be done using &lt;/span&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 10pt;"&gt;XamlReader&lt;/span&gt;&lt;/strong&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt; class in &lt;/span&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 10pt;"&gt;System.Windows.Markup&lt;/span&gt;&lt;/strong&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt; namespace. Let’s have a quick look that how it works: &lt;/span&gt;&lt;span serif="; mso-fareast-font-family: 'Times New Roman'" times="" roman="," new="" style="font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 10pt;"&gt;Create a new Project &lt;/span&gt;&lt;/strong&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;Create a new WPF Application in Visual Studio. You’ll get a Window1.xaml file in your project ready to be run as main Window of your application with following XAML document: &lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Window&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt; x&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;:&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt;Class&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;="WpfLsArticle2.Window1"&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;span style="color: red;"&gt;&lt;span style=""&gt; &lt;/span&gt;xmlns&lt;/span&gt;&lt;span style="color: blue;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;span style="color: red;"&gt;&lt;span style=""&gt; &lt;/span&gt;xmlns&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: red;"&gt;x&lt;/span&gt;&lt;span style="color: blue;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;span style="color: red;"&gt;&lt;span style=""&gt; &lt;/span&gt;Title&lt;/span&gt;&lt;span style="color: blue;"&gt;="Window1"&lt;/span&gt;&lt;span style="color: red;"&gt; Height&lt;/span&gt;&lt;span style="color: blue;"&gt;="285"&lt;/span&gt;&lt;span style="color: red;"&gt; Width&lt;/span&gt;&lt;span style="color: blue;"&gt;="314"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Grid&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Grid&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Window&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;You’ll also get a file Window1.xaml.cs which will be having code for your event handlers. Now, we want some control to be added inside the grid of Window1 at runtime based on user role so let’s create a XAML file which looks like the following: &lt;/span&gt;&lt;span serif="; mso-fareast-font-family: 'Times New Roman'" times="" roman="," new="" style="font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 10pt;"&gt;Create a separate XAML Document &lt;/span&gt;&lt;/strong&gt;&lt;span serif="; mso-fareast-font-family: 'Times New Roman'" times="" roman="," new="" style="font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Grid&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt; &lt;span style="color: red;"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;&lt;span style=""&gt;       &lt;/span&gt;&lt;span style="color: red;"&gt;&lt;span style=""&gt; &lt;/span&gt;xmlns&lt;/span&gt;&lt;span style="color: blue;"&gt;:&lt;/span&gt;&lt;span style="color: red;"&gt;x&lt;/span&gt;&lt;span style="color: blue;"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&amp;gt;&lt;/span&gt;&lt;span style="color: rgb(163, 21, 21);"&gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Button&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt; x&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;:&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt;Name&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;="userButton"&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt; Background&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;="Green"&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt; Content&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;="User Button" /&amp;gt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Button&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt; x&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;:&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt;Name&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;="adminButton"&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt; Background&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;="Red"&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: red;"&gt; Content&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;="Admin Button" /&amp;gt;&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt; &lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;Grid&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;There must be one and only root element in each valid XAML file so we are using a Grid as a root element. Then we have added two buttons to it as you can see from the above XAML document. Lets save this document as Controls.xaml. &lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(163, 21, 21);"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;strong&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 10pt;"&gt;Loading the XAML and Adding Controls and Runtime&lt;/span&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 13.5pt;"&gt; &lt;/span&gt;&lt;/strong&gt;&lt;span trebuchet="" ms="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;Use this code in Window’s Loaded event handler or in any other place depending on the application needs: &lt;/span&gt;&lt;span serif="; mso-fareast-font-family: 'Times New Roman'" times="" roman="," new="" style="font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;using&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;FileStream&lt;/span&gt; xamlFile = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;FileStream&lt;/span&gt;(&lt;span style="color: rgb(163, 21, 21);"&gt;"Controls.xaml"&lt;/span&gt;, &lt;span style="color: rgb(43, 145, 175);"&gt;FileMode&lt;/span&gt;.Open, &lt;span style="color: rgb(43, 145, 175);"&gt;FileAccess&lt;/span&gt;.Read)) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;{ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;span style=""&gt;     &lt;/span&gt;&lt;span style="color: blue;"&gt;string&lt;/span&gt;[] roles = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt;[] { &lt;span style="color: rgb(163, 21, 21);"&gt;"Admin"&lt;/span&gt;, &lt;span style="color: rgb(163, 21, 21);"&gt;"User"&lt;/span&gt; }; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; text-indent: 0.5in; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(43, 145, 175);"&gt;Random&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt; rand = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: rgb(43, 145, 175);"&gt;Random&lt;/span&gt;(); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; text-indent: 0.5in; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;int&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt; currentRoleId = rand.Next(0, 2); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; text-indent: 0.5in; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: green;"&gt;// XamlReader.Load method returns the root element of passed XAML stream. In our case it is a Grid &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; text-indent: 0.5in; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(43, 145, 175);"&gt;Grid&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt; rootElement = (&lt;span style="color: rgb(43, 145, 175);"&gt;Grid&lt;/span&gt;)&lt;span style="color: rgb(43, 145, 175);"&gt;XamlReader&lt;/span&gt;.Load(xamlFile); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;&lt;span style=""&gt;                &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; text-indent: 0.5in; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;if&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;String&lt;/span&gt;.Equals(roles[currentRoleId], &lt;span style="color: rgb(163, 21, 21);"&gt;"Admin"&lt;/span&gt;, &lt;span style="color: rgb(43, 145, 175);"&gt;StringComparison&lt;/span&gt;.Ordinal)) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; text-indent: 0.5in; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;{ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt 0.5in; text-indent: 0.5in; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(43, 145, 175);"&gt;Button&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt; button = (&lt;span style="color: rgb(43, 145, 175);"&gt;Button&lt;/span&gt;)rootElement.FindName(&lt;span style="color: rgb(163, 21, 21);"&gt;"adminButton"&lt;/span&gt;); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt 0.5in; text-indent: 0.5in; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;rootElement.Children.Remove(button); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt 0.5in; text-indent: 0.5in; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;this&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;.mainGrid.Children.Add(button); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; text-indent: 0.5in; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;} &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; text-indent: 0.5in; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;else&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (&lt;span style="color: rgb(43, 145, 175);"&gt;String&lt;/span&gt;.Equals(roles[currentRoleId], &lt;span style="color: rgb(163, 21, 21);"&gt;"User"&lt;/span&gt;, &lt;span style="color: rgb(43, 145, 175);"&gt;StringComparison&lt;/span&gt;.Ordinal)) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; text-indent: 0.5in; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;{ &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt 0.5in; text-indent: 0.5in; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: rgb(43, 145, 175);"&gt;Button&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt; button = (&lt;span style="color: rgb(43, 145, 175);"&gt;Button&lt;/span&gt;)rootElement.FindName(&lt;span style="color: rgb(163, 21, 21);"&gt;"userButton"&lt;/span&gt;); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt 0.5in; text-indent: 0.5in; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;rootElement.Children.Remove(button); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 0pt 0.5in; text-indent: 0.5in; line-height: normal;" class="MsoNormal1"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt; color: blue;"&gt;this&lt;/span&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;.mainGrid.Children.Add(button); &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; text-indent: 0.5in; line-height: normal;" class="MsoNormalCxSpMiddle"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;} &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormalCxSpMiddle"&gt;&lt;span courier="" new="; mso-no-proof: yes" style="font-size: 10pt;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormalCxSpMiddle"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;This is only a simplest example to show that it works&lt;/span&gt;&lt;span style="font-size: 8pt; font-family: wingdings;"&gt;&lt;span style=""&gt;J&lt;/span&gt;&lt;/span&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt; but you can actually load very complex prebuild heirarchy and set it to some portion of UI as a content, can manipulate properties in that heirachy, attach events and so on. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormalCxSpMiddle"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 5.2pt; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 12pt;"&gt;Conclusion&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 5.2pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;XAML is a very useful and extremely simple XML based language. Though it is not necessary for WPF development but it plays a major role in WPF and commercially there may not be any WPF application without it.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormalCxSpMiddle"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 5.2pt; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 12pt;"&gt;Assessment &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 5.2pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;After reading this article you should be able to understand: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; margin-left: 0.5in; text-indent: -0.25in;" class="MsoListParagraph"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: Arial" style="font-size: 10pt;"&gt;&lt;span style=""&gt;1.&lt;span times="" roman="" new=""&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span arial="," sans-serif="" style="font-size: 10pt;"&gt;Usefulness of XAML &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; margin-left: 0.5in; text-indent: -0.25in;" class="MsoListParagraph"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: Arial" style="font-size: 10pt;"&gt;&lt;span style=""&gt;2.&lt;span times="" roman="" new=""&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span arial="," sans-serif="" style="font-size: 10pt;"&gt;Role of XML Elements and Attributes in XAML &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; margin-left: 0.5in; text-indent: -0.25in;" class="MsoListParagraph"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: Arial" style="font-size: 10pt;"&gt;&lt;span style=""&gt;3.&lt;span times="" roman="" new=""&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span arial="," sans-serif="" style="font-size: 10pt;"&gt;Namespaces &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; margin-left: 0.5in; text-indent: -0.25in;" class="MsoListParagraph"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: Arial" style="font-size: 10pt;"&gt;&lt;span style=""&gt;4.&lt;span times="" roman="" new=""&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span arial="," sans-serif="" style="font-size: 10pt;"&gt;How to load, parse XAML and then use it to dynamically build some part of UI. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; margin-left: 0.5in; text-indent: -0.25in;" class="MsoListParagraph"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: Arial" style="font-size: 10pt;"&gt;&lt;span style=""&gt;5.&lt;span times="" roman="" new=""&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span arial="," sans-serif="" style="font-size: 10pt;"&gt;XAML compilation process. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; margin-left: 0.5in; text-indent: -0.25in;" class="MsoListParagraph"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: Arial" style="font-size: 10pt;"&gt;&lt;span style=""&gt;6.&lt;span times="" roman="" new=""&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span arial="," sans-serif="" style="font-size: 10pt;"&gt;BAML&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormalCxSpFirst"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 5.2pt; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 12pt;"&gt;What’s next?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 5.2pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;In next article, we’ll be talking about some new concepts introduced in WPF such as Logical and Visual Trees Routed Events etc. I’ll try my best to publish next article in next 3 days so stay tuned.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 5.2pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;Though I tried my best to go as much deep as possible but article kept growing so I missed a few things and would recommend you reading them as well.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormalCxSpLast"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;These&lt;span style=""&gt;  &lt;/span&gt;are:&lt;/span&gt;&lt;span serif="; mso-fareast-font-family: 'Times New Roman'" times="" roman="," new="" style="font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in 0pt 0.25in; text-indent: -0.25in;" class="MsoListParagraphCxSpFirst"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: Arial" style="font-size: 10pt;"&gt;&lt;span style=""&gt;1.&lt;span times="" roman="" new=""&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span arial="," sans-serif="" style="font-size: 10pt;"&gt;Attached Properties&lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in 0pt 0.25in; text-indent: -0.25in;" class="MsoListParagraphCxSpMiddle"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: Arial" style="font-size: 10pt;"&gt;&lt;span style=""&gt;2.&lt;span times="" roman="" new=""&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span arial="," sans-serif="" style="font-size: 10pt;"&gt;Handling Special Characters in XAML&lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 5.2pt 0in 0pt 0.25in; text-indent: -0.25in;" class="MsoListParagraphCxSpLast"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: Arial" style="font-size: 10pt;"&gt;&lt;span style=""&gt;3.&lt;span times="" roman="" new=""&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span arial="," sans-serif="" style="font-size: 10pt;"&gt;Content Property&lt;/span&gt;&lt;span trebuchet="" ms="," sans-serif="" style="font-size: 13.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0pt; line-height: normal;" class="MsoNormalCxSpFirst"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 5.2pt; line-height: normal;" class="MsoNormal1"&gt;&lt;strong style=""&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt" style="font-size: 12pt;"&gt;Feedback&lt;/span&gt;&lt;/strong&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 5.2pt; line-height: normal;" class="MsoNormal1"&gt;&lt;span arial="," sans-serif="; mso-fareast-font-family: 'Times New Roman'" style="font-size: 10pt;"&gt;Your comments, feedbacks, suggestions, corrections and questions are most welcome. They’ll help both you and me learn the most from each other.&lt;/span&gt;&lt;span serif="; mso-fareast-font-family: 'Times New Roman'" times="" roman="," new="" style="font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=118066"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=118066" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/RizwanSharp/aggbug/118066.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>RizwanSharp</dc:creator>
            <guid>http://geekswithblogs.net/RizwanSharp/archive/2007/12/31/deep-dive-into-xaml-part-2-of-wpf-learning-series.aspx</guid>
            <pubDate>Mon, 31 Dec 2007 06:08:25 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/RizwanSharp/comments/118066.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/RizwanSharp/archive/2007/12/31/deep-dive-into-xaml-part-2-of-wpf-learning-series.aspx#feedback</comments>
            <slash:comments>11</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/RizwanSharp/comments/commentRss/118066.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/RizwanSharp/services/trackbacks/118066.aspx</trackback:ping>
        </item>
    </channel>
</rss>