<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><!-- generator="wordpress/2.2.1" --><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>rubydoes.net</title>
	<link>http://rubydoes.net</link>
	<description>and we love it</description>
	<pubDate>Wed, 27 Aug 2008 12:16:51 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/rubydoesdotnet" type="application/rss+xml" /><item>
		<title>Code camp IronRuby presentation materials</title>
		<link>http://feeds.feedburner.com/~r/rubydoesdotnet/~3/376139448/</link>
		<comments>http://rubydoes.net/2008/08/27/code-camp-ironruby-presentation-materials/#comments</comments>
		<pubDate>Wed, 27 Aug 2008 12:16:51 +0000</pubDate>
		<dc:creator>Aaron Junod</dc:creator>
		
		<category><![CDATA[CodeCamp]]></category>

		<category><![CDATA[events]]></category>

		<category><![CDATA[IronRuby]]></category>

		<guid isPermaLink="false">http://rubydoes.net/2008/08/27/code-camp-ironruby-presentation-materials/</guid>
		<description><![CDATA[For those of you that were able to come see me ramble on about IronRuby thanks, and I hope you didn&#8217;t get bored to sleep. As promised, here are the presentation materials. Of course I said they would be up by the end of the day, I just didn&#8217;t say which day.
Code
PDF of slides
]]></description>
			<content:encoded><![CDATA[<p>For those of you that were able to come see me ramble on about IronRuby thanks, and I hope you didn&#8217;t get bored to sleep. As promised, here are the presentation materials. Of course I said they would be up by the end of the day, I just didn&#8217;t say which day.</p>
<p><a href="http://rubydoes.net/attach/ct_code_camp_code.zip">Code</a></p>
<p><a href="http://rubydoes.net/attach/ironruby_presentation.pdf">PDF of slides</a></p>
]]></content:encoded>
			<wfw:commentRss>http://rubydoes.net/2008/08/27/code-camp-ironruby-presentation-materials/feed/</wfw:commentRss>
		<feedburner:origLink>http://rubydoes.net/2008/08/27/code-camp-ironruby-presentation-materials/</feedburner:origLink></item>
		<item>
		<title>White paper on IronRuby published</title>
		<link>http://feeds.feedburner.com/~r/rubydoesdotnet/~3/374919222/</link>
		<comments>http://rubydoes.net/2008/08/25/white-paper-on-ironruby-published/#comments</comments>
		<pubDate>Tue, 26 Aug 2008 05:14:51 +0000</pubDate>
		<dc:creator>casualjim</dc:creator>
		
		<category><![CDATA[IronRuby]]></category>

		<guid isPermaLink="false">http://rubydoes.net/2008/08/25/white-paper-on-ironruby-published/</guid>
		<description><![CDATA[Manning published my white paper &#8212; or green paper as they call it &#8212; on IronRuby. 
You can find it here: http://manning.com/free/green_carrero.html
This paper tries to give you an introduction on what the ruby language is and how it could work for you. If you want to know more than what&#8217;s on those pages there is [...]]]></description>
			<content:encoded><![CDATA[<p>Manning published my white paper &#8212; or green paper as they call it &#8212; on IronRuby. </p>
<p>You can find it here: <a title="http://manning.com/free/green_carrero.html" href="http://manning.com/free/green_carrero.html">http://manning.com/free/green_carrero.html</a></p>
<p>This paper tries to give you an introduction on what the ruby language is and how it could work for you. If you want to know more than what&#8217;s on those pages there is always the book: <a href="http://manning.com/carrero">http://manning.com/carrero</a></p>
<div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:493a5def-c776-4df6-ae3c-eec188c7bced" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati Tags: <a href="http://technorati.com/tags/IronRuby" rel="tag">IronRuby</a></div>
]]></content:encoded>
			<wfw:commentRss>http://rubydoes.net/2008/08/25/white-paper-on-ironruby-published/feed/</wfw:commentRss>
		<feedburner:origLink>http://rubydoes.net/2008/08/25/white-paper-on-ironruby-published/</feedburner:origLink></item>
		<item>
		<title>IronNails: Rails like development for IronRuby with WPF/Silverlight</title>
		<link>http://feeds.feedburner.com/~r/rubydoesdotnet/~3/358486200/</link>
		<comments>http://rubydoes.net/2008/08/07/ironnails-rails-like-development-for-ironruby-with-wpfsilverlight/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 14:55:22 +0000</pubDate>
		<dc:creator>casualjim</dc:creator>
		
		<category><![CDATA[xaml]]></category>

		<category><![CDATA[Silverlight]]></category>

		<category><![CDATA[IronRuby]]></category>

		<guid isPermaLink="false">http://rubydoes.net/2008/08/07/ironnails-rails-like-development-for-ironruby-with-wpfsilverlight/</guid>
		<description><![CDATA[Whilst writing my book I stumbled upon a way to write WPF applications with an MVC paradigm.
You can read more about it on my blog: http://flanders.co.nz/2008/08/07/ironnails-introduction/
It&#8217;s still very early days for this project but if you like the concept and you have some free time please feel free to contribute. You can contact me through [...]]]></description>
			<content:encoded><![CDATA[<p>Whilst writing my book I stumbled upon a way to write WPF applications with an MVC paradigm.</p>
<p>You can read more about it on my blog: <a title="http://flanders.co.nz/2008/08/07/ironnails-introduction/" href="http://flanders.co.nz/2008/08/07/ironnails-introduction/">http://flanders.co.nz/2008/08/07/ironnails-introduction/</a></p>
<p>It&#8217;s still very early days for this project but if you like the concept and you have some free time please feel free to contribute. You can contact me through my blog or through github.</p>
<p>The github project can be found here: <a href="http://github.com/casualjim/ironnails">http://github.com/casualjim/ironnails</a></p>
<div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:438f9384-77ab-4fd5-805e-a24537a7afa7" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati Tags: <a href="http://technorati.com/tags/IronRubyInAction" rel="tag">IronRubyInAction</a>,<a href="http://technorati.com/tags/IronRuby" rel="tag">IronRuby</a>,<a href="http://technorati.com/tags/ironnails" rel="tag">ironnails</a>,<a href="http://technorati.com/tags/WPF" rel="tag">WPF</a></div>
]]></content:encoded>
			<wfw:commentRss>http://rubydoes.net/2008/08/07/ironnails-rails-like-development-for-ironruby-with-wpfsilverlight/feed/</wfw:commentRss>
		<feedburner:origLink>http://rubydoes.net/2008/08/07/ironnails-rails-like-development-for-ironruby-with-wpfsilverlight/</feedburner:origLink></item>
		<item>
		<title>Dynamic Script Control</title>
		<link>http://feeds.feedburner.com/~r/rubydoesdotnet/~3/310170930/</link>
		<comments>http://rubydoes.net/2008/06/11/dynamic-script-control/#comments</comments>
		<pubDate>Thu, 12 Jun 2008 05:12:41 +0000</pubDate>
		<dc:creator>casualjim</dc:creator>
		
		<category><![CDATA[xaml]]></category>

		<category><![CDATA[IronPython]]></category>

		<category><![CDATA[Silverlight]]></category>

		<category><![CDATA[IronRuby]]></category>

		<guid isPermaLink="false">http://rubydoes.net/2008/06/11/dynamic-script-control/</guid>
		<description><![CDATA[Both Silverlight and WPF use XAML markup to describe their user interface.&#160; As I&#8217;m currently writing my chapter on WPF for my book IronRuby In Action and I want to use some xaml that has been generated before for a different project but with an IronRuby class to load the xaml I&#8217;m in trouble. This [...]]]></description>
			<content:encoded><![CDATA[<p>Both Silverlight and WPF use XAML markup to describe their user interface.&#160; As I&#8217;m currently writing my chapter on WPF for my book IronRuby In Action and I want to use some xaml that has been generated before for a different project but with an IronRuby class to load the xaml I&#8217;m in trouble. This is because you can declare assembly references in the xml namespace declarations so you can use the types in that assembly from xaml.&#160; </p>
<p>The DLR based languages don&#8217;t compile into static assemblies and this means that you can&#8217;t use those xml namespace definitons to reference your assemblies.&#160; I wrote a fairly trivial control that acts like a hook for DLR based controls in the XAML tree.</p>
<p>You can check it out at codeplex.   <br /><a href="http://codeplex.com/dynamicscriptcontrol" target="_blank">http://codeplex.com/dynamicscriptcontrol</a></p>
<p>The idea behind this control is that you can &quot;hook&quot; your DLR based control into the visual tree by setting some properties.&#160; You can set properties on the DLR based control by setting the Attributes property on the DynamicScriptControl</p>
<p>Let&#8217;s look at a quick example:</p>
<p>1. The ruby file defining a custom TextBox. But you can do whatever&#160; you want in that ruby file of course.</p>
<p><a href="http://rubydoes.net/wp-content/uploads/2008/06/dynamic-script-control-rubyscript.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="120" alt="dynamic_script_control_rubyscript" src="http://rubydoes.net/wp-content/uploads/2008/06/dynamic-script-control-rubyscript-thumb.png" width="327" border="0" /></a> </p>
<p>All this textbox does is preset it&#8217;s text property to &quot;I&#8217;m prefilled&quot; </p>
<p>2. The xaml for the window</p>
<p><a href="http://rubydoes.net/wp-content/uploads/2008/06/dynamic-script-control-window-xaml.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="265" alt="dynamic_script_control_window_xaml" src="http://rubydoes.net/wp-content/uploads/2008/06/dynamic-script-control-window-xaml-thumb.png" width="504" border="0" /></a>&#160;</p>
<p>You first declare a namespace for the assembly that has the DynamicScriptControl. Next I have a StackPanel that contains 2 DynamicScriptControls. The first just contains the 2 mandatory properties. We need to know which class you want to instantiate in the file you provide by setting the ScriptFile property. This script file property is a path to your ruby file in my case prefilled_text_box.rb.   <br />The second DynamicScriptControl is one where I want to initialize the control with my own text property. To declare those properties you have to add them to the Attributes collection of the DynamicScriptControl. At this moment it&#8217;s not smart enough to know which datatype you give it so you can specify a format string which was necessary in this case because text is a string.</p>
<p>3. The result</p>
<p><a href="http://rubydoes.net/wp-content/uploads/2008/06/dynamic-script-control-window.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="309" alt="dynamic_script_control_window" src="http://rubydoes.net/wp-content/uploads/2008/06/dynamic-script-control-window-thumb.png" width="305" border="0" /></a> </p>
<p>Michael Foord the author of IronPython In Action will provide the python integration in this control. </p>
<p>There was a release of the Dynamic Silverlight SDK earlier this week which contained the necessary source code files to compile a common DLR for both IronRuby and IronPython.&#160; That is what makes it possible to support multiple scripting languages from the start.&#160; </p>
<p>I&#8217;ve hosted the source code on google and you can find that at:</p>
<p><a title="The google code project" href="http://code.google.com/p/dynamic-script-control" target="_blank">http://code.google.com/p/dynamic-script-control</a></p>
<div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:4015ed95-7a36-4820-ac0b-6344a61307ee" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati Tags: <a href="http://technorati.com/tags/ironruby" rel="tag">ironruby</a>,<a href="http://technorati.com/tags/WPF" rel="tag">WPF</a>,<a href="http://technorati.com/tags/DLR" rel="tag">DLR</a>,<a href="http://technorati.com/tags/ironpython" rel="tag">ironpython</a>,<a href="http://technorati.com/tags/Silverlight" rel="tag">Silverlight</a></div>
]]></content:encoded>
			<wfw:commentRss>http://rubydoes.net/2008/06/11/dynamic-script-control/feed/</wfw:commentRss>
		<feedburner:origLink>http://rubydoes.net/2008/06/11/dynamic-script-control/</feedburner:origLink></item>
		<item>
		<title>The IronRuby in Action book went into EAP today</title>
		<link>http://feeds.feedburner.com/~r/rubydoesdotnet/~3/291211969/</link>
		<comments>http://rubydoes.net/2008/05/15/the-ironruby-in-action-book-went-into-eap-today/#comments</comments>
		<pubDate>Thu, 15 May 2008 21:40:30 +0000</pubDate>
		<dc:creator>casualjim</dc:creator>
		
		<category><![CDATA[IronRuby]]></category>

		<guid isPermaLink="false">http://rubydoes.net/2008/05/15/the-ironruby-in-action-book-went-into-eap-today/</guid>
		<description><![CDATA[It&#8217;s been a bit of journey but my IronRuby in Action book finally went into EAP today. EAP means exactly what it means in the software world, still very much subject to change. This could be seen as a public review :)&#160; I welcome any suggestions you may have.
You can find the book at http://manning.com/carrero [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a bit of journey but my <a title="IronRuby in Action manning site" href="http://manning.com/carrero" target="_blank">IronRuby in Action</a> book finally went into EAP today. EAP means exactly what it means in the software world, still very much subject to change. This could be seen as a public review :)&#160; I welcome any suggestions you may have.</p>
<p>You can find the book at <a href="http://manning.com/carrero">http://manning.com/carrero</a>     <br />There is also a forum there where you can post suggestions and/or problems you may encounter when running the code samples. I look at it as my issue tracker <img src='http://rubydoes.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I&#8217;m currently working on a chapter where I build a complete twitter client with IronRuby and WPF (not silverlight as indicated on the current TOC). It is based on Witty but uses IronRuby instead of C# to drive the xaml. Also some storyboards have been replaced by IronRuby instead of by xaml stuff. It&#8217;s also not a straight port of Witty because I haven&#8217;t really looked at their code apart from the xaml that is.</p>
<p>Happy reading <img src='http://rubydoes.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:84f000d4-7f8c-4995-acfa-704bcc4023eb" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati Tags: <a href="http://technorati.com/tags/IronRuby" rel="tag">IronRuby</a>,<a href="http://technorati.com/tags/IronRubyInAction" rel="tag">IronRubyInAction</a></div>
]]></content:encoded>
			<wfw:commentRss>http://rubydoes.net/2008/05/15/the-ironruby-in-action-book-went-into-eap-today/feed/</wfw:commentRss>
		<feedburner:origLink>http://rubydoes.net/2008/05/15/the-ironruby-in-action-book-went-into-eap-today/</feedburner:origLink></item>
		<item>
		<title>Silverlight / IronRuby using controls (Part 2)</title>
		<link>http://feeds.feedburner.com/~r/rubydoesdotnet/~3/272644149/</link>
		<comments>http://rubydoes.net/2008/04/17/silverlight-ironruby-using-controls-part-2/#comments</comments>
		<pubDate>Fri, 18 Apr 2008 04:43:36 +0000</pubDate>
		<dc:creator>casualjim</dc:creator>
		
		<category><![CDATA[Silverlight]]></category>

		<category><![CDATA[IronRuby]]></category>

		<guid isPermaLink="false">http://rubydoes.net/2008/04/17/silverlight-ironruby-using-controls-part-2/</guid>
		<description><![CDATA[I&#8217;m sorry I didn&#8217;t post the last 2 days, but we&#8217;re back with a new post. In my previous posts (1, 2) we didn&#8217;t use the files as they are generated by the little DSL script, this was chosen purposely so you would know that you don&#8217;t really need those files.
Today we are going to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m sorry I didn&#8217;t post the last 2 days, but we&#8217;re back with a new post. In my <a href="http://rubydoes.net/2008/04/15/silverlight-ironruby-using-controls/" target="_blank">previous post</a>s (<a href="http://rubydoes.net/2008/04/14/silverlight-minimal-examples/" target="_blank">1</a>, <a href="http://rubydoes.net/2008/04/15/silverlight-ironruby-using-controls/" target="_blank">2</a>) we didn&#8217;t use the files as they are generated by the little DSL script, this was chosen purposely so you would know that you don&#8217;t really need those files.</p>
<p>Today we are going to use the files that get generated by the DSL script. We&#8217;re going to add some classes to silverlight.rb to enable a nicer api for generating elements from ruby.  We left off last time with some code to generate 3 elements. That code wasn&#8217;t the prettiest code I&#8217;ve ever seen, apparently John Lam agrees and he has written a little DSL script for generating those elements. In today&#8217;s post we&#8217;ll be using that little script to generate the StackPanel etc.</p>
<p><a href="http://rubydoes.net/wp-content/uploads/2008/04/controlsdemo3.zip" title="Download the completed code">Download the completed code</a></p>
<p>Just a refresher, here&#8217;s the code we ended up with the last time.</p>
<div class="ch_code_container" style="font-family: monospace;height:300px;">
<div style="">Code (ruby)</div>
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">require</span> &#8216;<span style="color:#CC0066; font-weight:bold;">System</span>.<span style="color:#9900CC;">Windows</span>.<span style="color:#9900CC;">Controls</span>,&#8217; +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&#8216; Version=<span style="color:#006666;">1.0</span><span style="color:#006666;">.0</span><span style="color:#006666;">.0</span>, Culture=neutral, PublicKeyToken=31bf3856ad364e35&#8242;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">require</span> &#8216;<span style="color:#CC0066; font-weight:bold;">System</span>.<span style="color:#9900CC;">Windows</span>.<span style="color:#9900CC;">Controls</span>.<span style="color:#9900CC;">Extended</span>, &#8216;+</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&#8216;Version=<span style="color:#006666;">1.0</span><span style="color:#006666;">.0</span><span style="color:#006666;">.0</span>, Culture=neutral, PublicKeyToken=31bf3856ad364e35&#8242;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">include</span> <span style="color:#CC0066; font-weight:bold;">System</span>::Windows</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">include</span> <span style="color:#CC0066; font-weight:bold;">System</span>::Windows::Controls</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">class</span> FrameworkElement</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> method_missing<span style="color:#006600; font-weight:bold;">&#40;</span>m<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; find_name<span style="color:#006600; font-weight:bold;">&#40;</span>m.<span style="color:#9900CC;">to_s</span>.<span style="color:#9900CC;">to_clr_string</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">xaml = Application.<span style="color:#9900CC;">current</span>.<span style="color:#9900CC;">load_root_visual</span><span style="color:#006600; font-weight:bold;">&#40;</span>Canvas.<span style="color:#9900CC;">new</span>, <span style="color:#996600;">&quot;app.xaml&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">textblock = xaml.<span style="color:#9900CC;">my_textblock</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">panel = StackPanel.<span style="color:#9900CC;">new</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">panel.<span style="color:#9900CC;">margin</span> = Thickness.<span style="color:#9900CC;">new</span> <span style="color:#006666;">50</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">panel.<span style="color:#9900CC;">orientation</span> = Orientation.<span style="color:#9900CC;">horizontal</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">button = Button.<span style="color:#9900CC;">new</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">button.<span style="color:#9900CC;">content</span> = &#8216;Push Me&#8217;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">button.<span style="color:#9900CC;">font_size</span> = <span style="color:#006666;">18</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">button.<span style="color:#9900CC;">margin</span> = Thickness.<span style="color:#9900CC;">new</span> <span style="color:#006666;">10</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">waterbox = WatermarkedTextBox.<span style="color:#9900CC;">new</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">waterbox.<span style="color:#9900CC;">font_size</span> = <span style="color:#006666;">18</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">waterbox.<span style="color:#9900CC;">margin</span> = Thickness.<span style="color:#9900CC;">new</span> <span style="color:#006666;">10</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">waterbox.<span style="color:#9900CC;">width</span> = <span style="color:#006666;">200</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">waterbox.<span style="color:#9900CC;">watermark</span> = &#8216;Type Something Here&#8217;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">panel.<span style="color:#9900CC;">children</span>.<span style="color:#9900CC;">add</span><span style="color:#006600; font-weight:bold;">&#40;</span>button<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">panel.<span style="color:#9900CC;">children</span>.<span style="color:#9900CC;">add</span><span style="color:#006600; font-weight:bold;">&#40;</span>waterbox<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">xaml.<span style="color:#9900CC;">children</span>.<span style="color:#9900CC;">add</span><span style="color:#006600; font-weight:bold;">&#40;</span>panel<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">button.<span style="color:#9900CC;">click</span> <span style="color:#9966CC; font-weight:bold;">do</span> |sender, e|</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; textblock.<span style="color:#9900CC;">text</span> = waterbox.<span style="color:#9900CC;">text</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
</ol>
</div>
<p>Let&#8217;s start replacing that code with something a little nicer. Open up the silverlight.rb file in your app folder and add the require directives at the top of your file. Next we&#8217;re going to need the Wpf::Builders module created by <a href="http://www.iunknown.com/2008/03/dynamic-silve-1.html" target="_blank">John Lam</a> it&#8217;s included in the download.  We&#8217;re going to need to add the following code in the silverlight.rb file:</p>
<div class="ch_code_container" style="font-family: monospace;height:300px;">
<div style="">Code (ruby)</div>
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">module</span> Wpf</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">module</span> Builders</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> name_collector</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; @___name_collector_</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#40;</span>name<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; name_collector<span style="color:#006600; font-weight:bold;">&#91;</span>name<span style="color:#006600; font-weight:bold;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> inject_names<span style="color:#006600; font-weight:bold;">&#40;</span>obj<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; name_collector.<span style="color:#9900CC;">each_pair</span> <span style="color:#9966CC; font-weight:bold;">do</span> |k, v|</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; obj.<span style="color:#9900CC;">instance_variable_set</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;@#{k}&quot;</span>.<span style="color:#9900CC;">to_sym</span>, v<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> evaluate_properties<span style="color:#006600; font-weight:bold;">&#40;</span>obj, args, &amp;b<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; obj.<span style="color:#9900CC;">instance_variable_set</span><span style="color:#006600; font-weight:bold;">&#40;</span>:@___name_collector_, name_collector<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; args.<span style="color:#9900CC;">each_pair</span> <span style="color:#9966CC; font-weight:bold;">do</span> |k, v|</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> k == :name</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name_collector<span style="color:#006600; font-weight:bold;">&#91;</span>v<span style="color:#006600; font-weight:bold;">&#93;</span> = obj</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; obj.<span style="color:#9900CC;">send</span> :<span style="color:#996600;">&quot;#{k.to_s}=&quot;</span>, v</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> obj.<span style="color:#9900CC;">respond_to</span>? :name</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; name_collector<span style="color:#006600; font-weight:bold;">&#91;</span>obj.<span style="color:#9900CC;">name</span><span style="color:#006600; font-weight:bold;">&#93;</span> = obj <span style="color:#9966CC; font-weight:bold;">unless</span> obj.<span style="color:#9900CC;">name</span>.<span style="color:#0000FF; font-weight:bold;">nil</span>?</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; obj</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> add_object_to_name_collector<span style="color:#006600; font-weight:bold;">&#40;</span>collection, obj, args = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>, &amp;b<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; obj = evaluate_properties<span style="color:#006600; font-weight:bold;">&#40;</span>obj, args, &amp;b<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; obj.<span style="color:#9900CC;">instance_eval</span><span style="color:#006600; font-weight:bold;">&#40;</span>&amp;b<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">unless</span> b.<span style="color:#0000FF; font-weight:bold;">nil</span>?</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; collection.<span style="color:#9900CC;">add</span> obj</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; obj</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> add_class_to_name_collector<span style="color:#006600; font-weight:bold;">&#40;</span>collection, klass, args = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>, &amp;b<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; obj = evaluate_properties<span style="color:#006600; font-weight:bold;">&#40;</span>klass.<span style="color:#9900CC;">new</span>, args, &amp;b<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; obj.<span style="color:#9900CC;">instance_eval</span><span style="color:#006600; font-weight:bold;">&#40;</span>&amp;b<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">unless</span> b.<span style="color:#0000FF; font-weight:bold;">nil</span>?</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; collection.<span style="color:#9900CC;">add</span> obj</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; obj</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> assign_to_name_collector<span style="color:#006600; font-weight:bold;">&#40;</span>property, klass, args = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>, &amp;b<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; obj = evaluate_properties<span style="color:#006600; font-weight:bold;">&#40;</span>klass.<span style="color:#9900CC;">new</span>, args, &amp;b<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; obj.<span style="color:#9900CC;">instance_eval</span><span style="color:#006600; font-weight:bold;">&#40;</span>&amp;b<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">unless</span> b.<span style="color:#0000FF; font-weight:bold;">nil</span>?</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">send</span> property, obj</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; obj</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">build</span><span style="color:#006600; font-weight:bold;">&#40;</span>klass, args = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>, &amp;b<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; obj = klass.<span style="color:#9900CC;">new</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; obj.<span style="color:#9900CC;">instance_variable_set</span><span style="color:#006600; font-weight:bold;">&#40;</span>:@___name_collector_, <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; args.<span style="color:#9900CC;">each_pair</span> <span style="color:#9966CC; font-weight:bold;">do</span> |k, v|</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> k == :name</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; obj.<span style="color:#9900CC;">name_collector</span><span style="color:#006600; font-weight:bold;">&#91;</span>v<span style="color:#006600; font-weight:bold;">&#93;</span> = obj</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; obj.<span style="color:#9900CC;">send</span> :<span style="color:#996600;">&quot;#{k.to_s}=&quot;</span>, v</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; obj.<span style="color:#9900CC;">instance_eval</span><span style="color:#006600; font-weight:bold;">&#40;</span>&amp;b<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">if</span> b != <span style="color:#0000FF; font-weight:bold;">nil</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; obj</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
</ol>
</div>
<p>That module takes care of dispatching the correct property names etc. Now that we have the module we can alter the SilverlightApplication a little bit. Let&#8217;s add a method add to that class that will be our entry point into the Wpf::Builders dsl.</p>
<div class="ch_code_container" style="font-family: monospace;height:100%;">
<div style="">Code (ruby)</div>
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">class</span> SilverlightApplication</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> add<span style="color:#006600; font-weight:bold;">&#40;</span>klass, args = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>, &amp;b<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; obj = Wpf.<span style="color:#9900CC;">build</span> klass, args, &amp;b</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; children.<span style="color:#9900CC;">add</span> obj</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
</ol>
</div>
<p>Ok we still need to monkey patch a couple other classes before we&#8217;re ready to go. The first thing we see is that StackPanel has a setter method for Margin that takes an instance of Thickness. The property margin is defined on FrameworkElement, so that we can use it on every object that inherits of FrameworkElement. We&#8217;re also going to be addressing objects by their name. Not all of them have a name setter method so we&#8217;re going to ensure that all of them have one by monkey patching DependencyObject</p>
<div class="ch_code_container" style="font-family: monospace;height:300px;">
<div style="">Code (ruby)</div>
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">class</span> FrameworkElement</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; alias_method :old_margin=, :margin=</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> margin=<span style="color:#006600; font-weight:bold;">&#40;</span>value<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">old_margin</span> = Thickness.<span style="color:#9900CC;">new</span> *value</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> method_missing<span style="color:#006600; font-weight:bold;">&#40;</span>m<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; find_name<span style="color:#006600; font-weight:bold;">&#40;</span>m.<span style="color:#9900CC;">to_s</span>.<span style="color:#9900CC;">to_clr_string</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">class</span> DependencyObject</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> name=<span style="color:#006600; font-weight:bold;">&#40;</span>value<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">set_value</span><span style="color:#006600; font-weight:bold;">&#40;</span>FrameworkElement.<span style="color:#9900CC;">NameProperty</span>, value.<span style="color:#9900CC;">to_clr_string</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
</ol>
</div>
<p>This gives us the ability to set margins as if it were normal integer values.</p>
<p>The next thing we see is that there is an Orientation property that we&#8217;re going to set and that seems to take an enumeration of some sort. To accomplish this we&#8217;re going to monkey patch StackPanel.</p>
<div class="ch_code_container" style="font-family: monospace;height:300px;">
<div style="">Code (ruby)</div>
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">class</span> StackPanel</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; alias_method :old_orientation= , :orientation=</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> orientation=<span style="color:#006600; font-weight:bold;">&#40;</span>value<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">old_orientation</span>= <span style="color:#9966CC; font-weight:bold;">case</span> value</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">when</span> :horizontal</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; Orientation.<span style="color:#9900CC;">horizontal</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">when</span> :vertical</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; Orientation.<span style="color:#9900CC;">vertical</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
</ol>
</div>
<p>We&#8217;re almost there don&#8217;t worry :). The next thing we see is that we need to be able to add child elements to that element. A StackPanel, DockPanel and so forth are all children of Panel so let&#8217;s patch Panel and enable this for more containers. To do this we need to include the module Wpf::Builders in the Panel class and we need to make sure we have all the necessary methods in there that will allow us to add children to that Panel.</p>
<div class="ch_code_container" style="font-family: monospace;height:300px;">
<div style="">Code (ruby)</div>
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">class</span> Panel</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">include</span> Wpf::Builders</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> add<span style="color:#006600; font-weight:bold;">&#40;</span>klass, args = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>, &amp;b<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; add_class_to_name_collector<span style="color:#006600; font-weight:bold;">&#40;</span>children, klass, args, &amp;b<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> add_name<span style="color:#006600; font-weight:bold;">&#40;</span>name, obj<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; name_collector<span style="color:#006600; font-weight:bold;">&#91;</span>name<span style="color:#006600; font-weight:bold;">&#93;</span> = obj</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> add_obj<span style="color:#006600; font-weight:bold;">&#40;</span>obj<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; add_object_to_name_collector<span style="color:#006600; font-weight:bold;">&#40;</span>children, obj<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
</ol>
</div>
<p>We&#8217;ve now got us a little DSL for generating the necessary elements for this demo. All that is left to do now is write the initialize method in app.rb so that we get the same result as the last demo. Below we&#8217;ve got the content of the app.rb file</p>
<div class="ch_code_container" style="font-family: monospace;height:300px;">
<div style="">Code (ruby)</div>
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">&quot;Silverlight&quot;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">class</span> App &lt; SilverlightApplication</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; use_xaml</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> initialize</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; add StackPanel, :margin =&gt; <span style="color:#006666;">50</span>, :orientation =&gt; :horizontal <span style="color:#9966CC; font-weight:bold;">do</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; add Button, :content =&gt; &#8216;push me&#8217;,</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :name =&gt; &#8216;my_button&#8217;,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :font_size =&gt; <span style="color:#006666;">18</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; add WatermarkedTextBox,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :font_size =&gt; <span style="color:#006666;">18</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :margin =&gt; <span style="color:#006666;">10</span>,</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :name =&gt; &#8216;my_waterbox&#8217;,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :width =&gt; <span style="color:#006666;">200</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :watermark =&gt; &#8216;Type something here&#8217;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; my_button.<span style="color:#9900CC;">click</span> <span style="color:#9966CC; font-weight:bold;">do</span> |sender, e|</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; my_textblock.<span style="color:#9900CC;">text</span> = my_waterbox.<span style="color:#9900CC;">text</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">App.<span style="color:#9900CC;">new</span></div>
</li>
</ol>
</div>
<p>I hope you can see that Silverlight and IronRuby can really work together to help you build some cool things easily. The next post will deal with some animation, hope to see you there <img src='http://rubydoes.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:5d5746be-3145-4909-a33f-44e01aeac9ad" style="margin: 0px; padding: 0px; display: inline">del.icio.us Tags: <a href="http://del.icio.us/popular/IronRuby" rel="tag">IronRuby</a>,<a href="http://del.icio.us/popular/Silverlight" rel="tag">Silverlight</a></p>
<p class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:6c4658b3-8c4a-456c-93dd-95aedd026b22" style="margin: 0px; padding: 0px; display: inline">Technorati Tags: <a href="http://technorati.com/tags/IronRuby" rel="tag">IronRuby</a>,<a href="http://technorati.com/tags/Silverlight" rel="tag">Silverlight</a></p>
]]></content:encoded>
			<wfw:commentRss>http://rubydoes.net/2008/04/17/silverlight-ironruby-using-controls-part-2/feed/</wfw:commentRss>
		<feedburner:origLink>http://rubydoes.net/2008/04/17/silverlight-ironruby-using-controls-part-2/</feedburner:origLink></item>
		<item>
		<title>Silverlight / IronRuby using controls</title>
		<link>http://feeds.feedburner.com/~r/rubydoesdotnet/~3/270620016/</link>
		<comments>http://rubydoes.net/2008/04/15/silverlight-ironruby-using-controls/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 10:34:34 +0000</pubDate>
		<dc:creator>casualjim</dc:creator>
		
		<category><![CDATA[Silverlight]]></category>

		<category><![CDATA[IronRuby]]></category>

		<guid isPermaLink="false">http://rubydoes.net/2008/04/15/silverlight-ironruby-using-controls/</guid>
		<description><![CDATA[In yesterdays post we covered the very basics of using IronRuby with Silverlight. Today we&#8217;re going to look at how we can use some of the basic controls that have been released for silverlight. One of the cool things about the controls is that Microsoft released the source code for them. Along with this source [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://rubydoes.net/2008/04/14/silverlight-minimal-examples/" target="_blank">yesterdays post</a> we covered the very basics of using IronRuby with Silverlight. Today we&#8217;re going to look at how we can use some of the basic controls that have been released for silverlight. One of the cool things about the controls is that Microsoft released the source code for them. Along with this source code they also released a test framework for testing your own controls. I think that is pretty cool <img src='http://rubydoes.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Shawn Burke explains <a href="http://blogs.msdn.com/sburke/archive/2008/03/05/silverlight-2-beta-1-controls-available-including-source-and-unit-tests.aspx" target="_blank">how to use the testing framework</a> they built for silverlight controls. In his blog post he also points you to the correct location for downloading the bits you need.</p>
<p>The next thing that is really cool about using silverlight is that it&#8217;s so easy to change the appearance of a silverlight control by using skinning. <a href="http://blogs.msdn.com/corrinab/" target="_blank">Corrina Barber</a> explains <a href="http://blogs.msdn.com/corrinab/archive/2008/03/11/silverlight-2-control-skins.aspx" target="_blank">how to go about that</a> and she also has 4 sets of skins for the standard controls available for download.<br />
See online previews of each skin:</p>
<ul>
<li><a href="http://www.corrina_b.members.winisp.net/skins/bubbly/Testpage.html">http://www.corrina_b.members.winisp.net/skins/bubbly/Testpage.html</a></li>
<li><a href="http://www.corrina_b.members.winisp.net/skins/red/Testpage.html">http://www.corrina_b.members.winisp.net/skins/red/Testpage.html</a></li>
<li><a href="http://www.corrina_b.members.winisp.net/skins/flat/Testpage.html">http://www.corrina_b.members.winisp.net/skins/flat/Testpage.html</a></li>
<li><a href="http://www.corrina_b.members.winisp.net/skins/rough/Testpage.html">http://www.corrina_b.members.winisp.net/skins/rough/Testpage.html</a></li>
</ul>
<p>Are you still here? Great <img src='http://rubydoes.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> Let&#8217;s look at some simple examples of using the standard controls that come with the Silverlight SDK. We won&#8217;t look into skinning those controls yet but for now will just look at how to use some of them. Like yesterday we&#8217;re going to look at 2 examples one that uses predominantly xaml and one that uses mostly ruby.</p>
<p>You can view the completed examples online:</p>
<ul>
<li><a href="http://flanders.co.nz/silverlight/controls/" title="http://flanders.co.nz/silverlight/controls/">http://flanders.co.nz/silverlight/controls/</a></li>
<li><a href="http://flanders.co.nz/silverlight/controls2/" title="http://flanders.co.nz/silverlight/controls2/">http://flanders.co.nz/silverlight/controls2/</a></li>
</ul>
<p>I got my Ruby In Steel to work again so in the code download I&#8217;ve included the Visual studio solution and project files.</p>
<blockquote><p><a href="http://rubydoes.net/wp-content/uploads/2008/04/silverlightcontrolsdemo.zip" target="_blank" title="The completed code for this article">Download the completed code</a></p></blockquote>
<p>The first sample will be mostly using xaml. The first thing we need to do is create a silverlight application. Just like yesterday I&#8217;ve removed the silverlight.rb file, but unlike yesterday we are not done preparing our app yet. The controls we&#8217;re going to be using for our samples live in Microsoft.Silverlight.Controls.dll and Microsoft.Silverlight.Controls.Extended.dll. These dll&#8217;s can be found on my pc in <em>C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Libraries\Client.</em>  Copy those controls to the app folder of your application.  We&#8217;re now one step away from completing the preparations. The last thing we need to do is tell our application it requires the assemblies that contain the controls. To do this we need to add them in an AppManifest.xaml file. To generate such an AppManifest.xaml file we can use chiron with the parameters /m and /d:app</p>
<p><a href="http://rubydoes.net/wp-content/uploads/2008/04/silverlight-controls-appmanifest.png"><img src="http://rubydoes.net/wp-content/uploads/2008/04/silverlight-controls-appmanifest-thumb.png" style="border: 0px none " alt="silverlight_controls_appmanifest" border="0" width="519" height="259" /></a></p>
<p>The file that got generated contains references to Microsoft.Silverlight.dll, as well as for the DLR (Microsoft.Scripting.dll) and for IronRuby (IronRuby.dll and IronRuby.Library.dll). We need to add the assemblies for the controls in this file.</p>
<p><a href="http://rubydoes.net/wp-content/uploads/2008/04/silverlight-controls-appmanifest-edited.png"><img src="http://rubydoes.net/wp-content/uploads/2008/04/silverlight-controls-appmanifest-edited-thumb.png" style="border: 0px none " alt="silverlight_controls_appmanifest_edited" border="0" width="519" height="255" /></a></p>
<p>We&#8217;re now ready to start developing an application. The xaml file for the first sample is a little bit too long to show here but feel free to download the code and have a look. Instead we&#8217;ll highlight the most important bits. For the xaml to work for the Button control we need to reference Microsoft.Silverlight.Controls and for the watermarked textbox we need Microsoft.Silverlight.Controls.Extended. We need to add reference to those in our app.xaml file by adding a namespace declaration of which the content looks like: <em>clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls </em></p>
<p><a href="http://rubydoes.net/wp-content/uploads/2008/04/silverlight-controls-references-in-xaml.png"><img src="http://rubydoes.net/wp-content/uploads/2008/04/silverlight-controls-references-in-xaml-thumb.png" style="border: 0px none " alt="silverlight_controls_references_in_xaml" border="0" width="519" height="98" /></a></p>
<p>We then added some controls to the app.xaml file as you can see in the download, but in mean time have a look at the <a href="http://flanders.co.nz/silverlight/controls">live demo</a>.  The ruby file that drives this xaml is very basic and only has 3 lines of code, all the code that is necessary to load the xaml file.</p>
<p><a href="http://rubydoes.net/wp-content/uploads/2008/04/silverlight-controls-app-rb.png"><img src="http://rubydoes.net/wp-content/uploads/2008/04/silverlight-controls-app-rb-thumb.png" style="border: 0px none " alt="silverlight_controls_app_rb" border="0" width="519" height="148" /></a></p>
<p>Our next example will allow us to do something more useful like responding to a click event on a button. This demo is more ruby centric and uses a very small xaml file, without references to the assemblies containing the controls.</p>
<p><a href="http://rubydoes.net/wp-content/uploads/2008/04/silverlight-controls2-xaml.png"><img src="http://rubydoes.net/wp-content/uploads/2008/04/silverlight-controls2-xaml-thumb.png" style="border: 0px none " alt="silverlight_controls2_xaml" border="0" width="519" height="154" /></a></p>
<p>Instead of adding the references in xaml we&#8217;re going to add them to our ruby file by using the ruby require statement.</p>
<p><a href="http://rubydoes.net/wp-content/uploads/2008/04/silverlight-controls2-references-ruby.png"><img src="http://rubydoes.net/wp-content/uploads/2008/04/silverlight-controls2-references-ruby-thumb.png" style="border: 0px none " alt="silverlight_controls2_references_ruby" border="0" width="519" height="62" /></a></p>
<p>Yesterday we saw how we could use find_name to retrieve a control and manipulate it. Today I added the method missing implementation from the silverlight.rb file to the ruby file. This will give us the ability to write xaml.control_name instead of xaml.find_name(&#8217;control_name&#8217;)</p>
<p><a href="http://rubydoes.net/wp-content/uploads/2008/04/silverlight-controls2-method-missing.png"><img src="http://rubydoes.net/wp-content/uploads/2008/04/silverlight-controls2-method-missing-thumb.png" style="border: 0px none " alt="silverlight_controls2_method_missing" border="0" width="519" height="77" /></a></p>
<p>The next part is adding some more controls to the canvas like a <em>StackPanel</em> that will contain a <em>Button</em> and a <em>WatermarkedTextbox</em>.   Tomorrow we&#8217;ll look at how we can pretty up that ruby code <img src='http://rubydoes.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> but for now we&#8217;re just going to use the standard api. We first create the instances of the controls and configure them. Next we add them to the panel and then we add the panel to the canvas.</p>
<p><a href="http://rubydoes.net/wp-content/uploads/2008/04/silverlight-controls2-adding-controls.png"><img src="http://rubydoes.net/wp-content/uploads/2008/04/silverlight-controls2-adding-controls-thumb.png" style="border: 0px none " alt="silverlight_controls2_adding_controls" border="0" width="519" height="309" /></a></p>
<p>The last step for our mini application to actually respond to an action from the user is to handle the click event on the button. Ruby makes this as easy as assigning a block to the click attribute on the button instance.</p>
<p><a href="http://rubydoes.net/wp-content/uploads/2008/04/silverlight-controls-handling-events.png"><img src="http://rubydoes.net/wp-content/uploads/2008/04/silverlight-controls-handling-events-thumb.png" style="border: 0px none " alt="silverlight_controls_handling_events" border="0" width="519" height="51" /></a></p>
<p>And that&#8217;s all for today. Tomorrow we&#8217;ll look at putting ruby to work for us and prettying up that api for adding elements to a silverlight control.</p>
<p class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:0e5dd167-449f-4756-b93f-2b05223359b8" style="margin: 0px; padding: 0px; display: inline">Technorati Tags: <a href="http://technorati.com/tags/silverlight" rel="tag">silverlight</a>,<a href="http://technorati.com/tags/ironruby" rel="tag">ironruby</a></p>
<p class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:b8fa2bc6-d9de-4760-9cb4-62c79b8dfabf" style="margin: 0px; padding: 0px; display: inline">del.icio.us Tags: <a href="http://del.icio.us/popular/silverlight" rel="tag">silverlight</a>,<a href="http://del.icio.us/popular/ironruby" rel="tag">ironruby</a></p>
]]></content:encoded>
			<wfw:commentRss>http://rubydoes.net/2008/04/15/silverlight-ironruby-using-controls/feed/</wfw:commentRss>
		<feedburner:origLink>http://rubydoes.net/2008/04/15/silverlight-ironruby-using-controls/</feedburner:origLink></item>
		<item>
		<title>IronRuby revision 93 posted</title>
		<link>http://feeds.feedburner.com/~r/rubydoesdotnet/~3/270648764/</link>
		<comments>http://rubydoes.net/2008/04/14/ironruby-revision-93-posted/#comments</comments>
		<pubDate>Mon, 14 Apr 2008 23:44:17 +0000</pubDate>
		<dc:creator>Aaron Junod</dc:creator>
		
		<category><![CDATA[mailinglist]]></category>

		<category><![CDATA[Source]]></category>

		<category><![CDATA[IronRuby]]></category>

		<guid isPermaLink="false">http://rubydoes.net/2008/04/14/ironruby-revision-93-posted/</guid>
		<description><![CDATA[John Lam has released revision 93 to SVN. This new release now passes 1541/2468 specs (62%). Click here to see the output of all the tests.
The highlights from the commit logs :

r89 Minor updates to Ruby to support hosting in ASP.NET
r93 A bunch of String specs have were re-enabled since we no longer crash when [...]]]></description>
			<content:encoded><![CDATA[<p>John Lam has released revision 93 to SVN. This new release now passes 1541/2468 specs (62%). <a href="http://rubydoes.net/attach/r93_specs.txt" >Click here</a> to see the output of all the tests.</p>
<p>The highlights from the commit logs :</p>
<ul>
<li>r89 Minor updates to Ruby to support hosting in ASP.NET</li>
<li>r93 A bunch of String specs have were re-enabled since we no longer crash when parsing them</li>
<li>A bunch of regex functionality (still using .NET regex) is enabled - =~, sub,gsub etc. are now implemented in this release.</li>
<li>There was a split in the way the DLR is organized. Microsoft.Scripting.Core.dll is the DLR, and Microsoft.Scripting.dll are where libraries like the Math libraries for the DLR will live from now on.</li>
</ul>
<p>To view the complete set of commit comments <a href="http://rubydoes.net/attach/r93_commit.txt" >click here</a></p>
<p>Seo Sanghyeon also updated the <a href="http://sparcs.kaist.ac.kr/~tinuviel/download/IronRuby/" title="mono howto">HOWTO and patches</a> for working with IronRuby from within Mono.</p>
<p>John Lam has also mentioned that since the release of r93 he has bee working heavily on String, specifically the parts of String required for running Rails. He reports 70% of String required to run Rails is passing!</p>
<p>Thanks again to the IronRuby team, both inside and outside Microsoft for their hard work!</p>
]]></content:encoded>
			<wfw:commentRss>http://rubydoes.net/2008/04/14/ironruby-revision-93-posted/feed/</wfw:commentRss>
		<feedburner:origLink>http://rubydoes.net/2008/04/14/ironruby-revision-93-posted/</feedburner:origLink></item>
		<item>
		<title>Silverlight minimal examples</title>
		<link>http://feeds.feedburner.com/~r/rubydoesdotnet/~3/269936363/</link>
		<comments>http://rubydoes.net/2008/04/14/silverlight-minimal-examples/#comments</comments>
		<pubDate>Mon, 14 Apr 2008 10:59:15 +0000</pubDate>
		<dc:creator>casualjim</dc:creator>
		
		<category><![CDATA[Silverlight]]></category>

		<category><![CDATA[IronRuby]]></category>

		<guid isPermaLink="false">http://rubydoes.net/2008/04/14/silverlight-minimal-examples/</guid>
		<description><![CDATA[I won&#8217;t be repeating the very basics of how to get started with silverlight here but will instead refer you to John Lam&#8217;s excellent blog post on the subject.  I do have to warn you for this series we won&#8217;t be using the silverlight.rb created by the dsl template generator.  I chose to do it [...]]]></description>
			<content:encoded><![CDATA[<p>I won&#8217;t be repeating the very basics of how to get started with silverlight here but will instead refer you to John Lam&#8217;s <a href="http://www.iunknown.com/2008/03/dynamic-silverl.html">excellent blog post</a> on the subject.  I do have to warn you for this series we won&#8217;t be using the silverlight.rb created by the dsl template generator.  I chose to do it this way so that you would better understand what is going on in the silverlight.rb file. I&#8217;ll assume from now on that you&#8217;re familiar with John&#8217;s post and move on.</p>
<p><a href="http://rubydoes.net/wp-content/uploads/2008/04/minimal_ir_projects.zip" title="Download the completed code">Download the completed code</a></p>
<p>You can see the end result of these 2 examples in action:<br />
<a href="http://flanders.co.nz/silverlight/minimal/index.html" target="_blank">http://flanders.co.nz/silverlight/minimal/index.html</a><br />
<a href="http://flanders.co.nz/silverlight/minimal2/index.html" target="_blank">http://flanders.co.nz/silverlight/minimal2/index.html</a></p>
<p>To run a silverlight website you don&#8217;t need a server side configuration. I&#8217;m hosting those examples on a linux box without mono installed. It&#8217;s just serving up files.</p>
<p>The first thing we need to do is create a skeleton for our application.</p>
<p>I did this by opening up Powershell (or the command prompt) and navigating to c:\projects\silverlight and executing the command dsl minimal_ir_project</p>
<p><a href="http://rubydoes.net/wp-content/uploads/2008/04/image.png"><img src="http://rubydoes.net/wp-content/uploads/2008/04/image-thumb.png" style="border-width: 0px" alt="image" border="0" width="519" height="287" /></a></p>
<p>Now that that&#8217;s done we&#8217;re going to delete silverlight.rb from the app folder. We can do that by going into that folder ( cd minimal_ir_project\app ) and executing del silverlight.rb Next we&#8217;re going to navigate one level up ( cd .. ) and start the webserver and default browser by executing chiron /b</p>
<p><a href="http://rubydoes.net/wp-content/uploads/2008/04/image1.png"><img src="http://rubydoes.net/wp-content/uploads/2008/04/image-thumb1.png" style="border-width: 0px" alt="image" border="0" width="519" height="287" /></a></p>
<p>At this point we&#8217;re entirely ready to start developing <img src='http://rubydoes.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> Let&#8217;s fire up an editor. For these examples I used <a href="http://notepad-plus.sourceforge.net/uk/site.htm">notepad++</a> because Ruby In Steel has been acting up and it seemed a bit overkill to start up visual studio for the amount of coding we need to do in these 2 examples.</p>
<p>I first opened up the app.xaml file and gave it the following content.</p>
<p><a href="http://rubydoes.net/wp-content/uploads/2008/04/app-xaml-rubydoes-net-minimal-sl1.png"><img src="http://rubydoes.net/wp-content/uploads/2008/04/app-xaml-rubydoes-net-minimal-sl1-thumb.png" style="border-width: 0px" alt="app_xaml_rubydoes_net_minimal_sl1" border="0" width="519" height="148" /></a></p>
<p>This xaml ensures us that we will have a canvas container object and a TextBlock with name <em>textblock. </em>We&#8217;ve also set the font size of the text to 30 and if we don&#8217;t change the text through ruby it will read Hello world from XAML. To be able to show this xaml we need to edit the app.rb file and give it the following content:</p>
<p><em>include System::Windows<br />
include System::Windows::Controls<br />
Application.current.load_root_visual Canvas.new, &#8220;app.xaml&#8221;</em></p>
<p>The first 2 lines in that file are just like using statements in C# and provide access to the types living in those namespaces without having to fully qualify them. So instead of having to write <em>System::Windows::Controls::Canvas</em> you can use <em>Canvas</em>. And the next line tells our silverlight application that the visual root control has to be loaded as a <em>Canvas </em>type from the file app.xaml</p>
<p>If you switch now to your browser and click on the index.html file you will see <strong>Hello world from XAML</strong> in your browser. Very impressive, feel free to say woohoo <img src='http://rubydoes.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> Let&#8217;s take it a little further and change the text of that text block to Hello world from IronRuby because after all it&#8217;s all about IronRuby.  To do that change the content from app.rb to:</p>
<p><a href="http://rubydoes.net/wp-content/uploads/2008/04/app-rb-rubydoes-net-minimal-sl1.png"><img src="http://rubydoes.net/wp-content/uploads/2008/04/app-rb-rubydoes-net-minimal-sl1-thumb.png" style="border-width: 0px" alt="app_rb_rubydoes_net_minimal_sl1" border="0" width="519" height="234" /></a></p>
<p>And the end result looks like this in Internet Explorer (Firefox 3 crashes with silverlight currently)</p>
<p><a href="http://rubydoes.net/wp-content/uploads/2008/04/hello-world-ironruby.png"><img src="http://rubydoes.net/wp-content/uploads/2008/04/hello-world-ironruby-thumb.png" style="border-width: 0px" alt="hello_world_ironruby" border="0" width="519" height="156" /></a></p>
<p>I think this would be the least amount of code you have to write to get going with silverlight development.</p>
<p>Let&#8217;s look at how that code would look when we don&#8217;t use xaml.</p>
<p>Let&#8217;s create a second project minimal_ir_project2 like before but now we delete both silverlight.rb and app.xml. The only file that is left now is app.rb Again you can start the webserver.</p>
<p>The content of app.rb should look like this:</p>
<p><a href="http://rubydoes.net/wp-content/uploads/2008/04/app-rb-no-xaml-rubydoes-net-minimal-sl2.png"><img src="http://rubydoes.net/wp-content/uploads/2008/04/app-rb-no-xaml-rubydoes-net-minimal-sl2-thumb.png" style="border-width: 0px" alt="app_rb_no_xaml_rubydoes_net_minimal_sl2" border="0" width="519" height="319" /></a></p>
<p>This ruby code has the same effect as the previous app.xaml. We first create a canvas object, next we create a TextBlock object and configure it&#8217;s properties. After that we add the textblock objects to the children collection of the canvas instance. And lastly we set the canvas object to be the root visual of our silverlight application. And all that hard work yields the following result:</p>
<p><a href="http://rubydoes.net/wp-content/uploads/2008/04/hello-world-ironruby2.png"><img src="http://rubydoes.net/wp-content/uploads/2008/04/hello-world-ironruby2-thumb.png" style="border-width: 0px" alt="hello_world_ironruby2" border="0" width="519" height="156" /></a></p>
<p>This concludes the first article in our series on Silverlight and IronRuby. Today we covered the very basics of silverlight development.</p>
<p class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:f8880bc1-efb8-42be-87ed-175889ff395c" style="margin: 0px; padding: 0px; display: inline">Technorati Tags: <a href="http://technorati.com/tags/ironruby" rel="tag">ironruby</a>,<a href="http://technorati.com/tags/silverlight" rel="tag">silverlight</a></p>
<p class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:8f9c2caa-6389-4250-9bfb-7d0a8603a78b" style="margin: 0px; padding: 0px; display: inline">del.icio.us Tags: <a href="http://del.icio.us/popular/ironruby" rel="tag">ironruby</a>,<a href="http://del.icio.us/popular/silverlight" rel="tag">silverlight</a></p>
]]></content:encoded>
			<wfw:commentRss>http://rubydoes.net/2008/04/14/silverlight-minimal-examples/feed/</wfw:commentRss>
		<feedburner:origLink>http://rubydoes.net/2008/04/14/silverlight-minimal-examples/</feedburner:origLink></item>
		<item>
		<title>Getting started with Silverlight and IronRuby</title>
		<link>http://feeds.feedburner.com/~r/rubydoesdotnet/~3/269296531/</link>
		<comments>http://rubydoes.net/2008/04/12/getting-started-with-silverlight-and-ironruby/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 06:07:35 +0000</pubDate>
		<dc:creator>casualjim</dc:creator>
		
		<category><![CDATA[IronPython]]></category>

		<category><![CDATA[Silverlight]]></category>

		<category><![CDATA[IronRuby]]></category>

		<guid isPermaLink="false">http://rubydoes.net/2008/04/12/getting-started-with-silverlight-and-ironruby/</guid>
		<description><![CDATA[This is my first post on this site and I hope there will be many more to come  I&#8217;m Ivan Porto Carrero and am currently writing a book on IronRuby for Manning. I decided to use this blog to post about IronRuby so that this site can become a really useful resource for people [...]]]></description>
			<content:encoded><![CDATA[<p>This is my first post on this site and I hope there will be many more to come <img src='http://rubydoes.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> I&#8217;m Ivan Porto Carrero and am currently writing a book on <a href="http://www.ironruby.net">IronRuby</a> for <a href="http://manning.com">Manning</a>. I decided to use this blog to post about IronRuby so that this site can become a really useful resource for people that want to get into <a href="http://www.ironruby.net">IronRuby</a>.</p>
<p>When the beta for <a href="http://silverlight.net">Silverlight</a> 2.0 was released it got support for <a href="http://www.ironruby.net">IronRuby</a>. I personally think that <a href="http://silverlight.net">Silverlight</a> and <a href="http://www.ironruby.net">IronRuby</a> is a winning team.&#160; But when you come from normal web development or windows forms development it does have little bit of a learning curve because of XAML.     <br />But once you get passed that learning curve it&#8217;s a pretty sweet technology to master <img src='http://rubydoes.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>There are other people that have blogged about <a href="http://silverlight.net">silverlight</a> and <a href="http://www.ironruby.net">IronRuby</a> before, it might be a good idea to check them out as well.</p>
<ul>
<li><a title="http://dynamicsilverlight.net/" href="http://dynamicsilverlight.net/">http://dynamicsilverlight.net/</a> </li>
<li><a title="http://www.iunknown.com/2008/03/dynamic-silverl.html" href="http://www.iunknown.com/2008/03/dynamic-silverl.html">http://www.iunknown.com/2008/03/dynamic-silverl.html</a> </li>
<li><a title="http://www.iunknown.com/2008/03/dynamic-silve-1.html" href="http://www.iunknown.com/2008/03/dynamic-silve-1.html">http://www.iunknown.com/2008/03/dynamic-silve-1.html</a> </li>
<li><a title="http://www.iunknown.com/2008/03/dynamic-silve-2.html" href="http://www.iunknown.com/2008/03/dynamic-silve-2.html">http://www.iunknown.com/2008/03/dynamic-silve-2.html</a> </li>
<li><a title="http://silverlight.net/Quickstarts/ProgramDlr.aspx" href="http://silverlight.net/Quickstarts/ProgramDlr.aspx">http://silverlight.net/Quickstarts/ProgramDlr.aspx</a> </li>
<li><a title="http://blog.jimmy.schementi.com/2008/03/dynamic-silverlight.html" href="http://blog.jimmy.schementi.com/2008/03/dynamic-silverlight.html">http://blog.jimmy.schementi.com/2008/03/dynamic-silverlight.html</a> </li>
<li><a title="http://www.dotnetguru2.org/tbarrere/index.php?title=step_by_step_debugging_with_silverlight_&amp;more=1&amp;c=1&amp;tb=1&amp;pb=1" href="http://www.dotnetguru2.org/tbarrere/index.php?title=step_by_step_debugging_with_silverlight_&amp;more=1&amp;c=1&amp;tb=1&amp;pb=1">http://www.dotnetguru2.org/tbarrere/index.php?title=step_by_step_debugging_with_silverlight_&amp;more=1&amp;c=1&amp;tb=1&amp;pb=1</a> </li>
<li><a title="http://flanders.co.nz/2008/04/06/an-ironruby-digg-client/" href="http://flanders.co.nz/2008/04/06/an-ironruby-digg-client/">http://flanders.co.nz/2008/04/06/an-ironruby-digg-client/</a> </li>
</ul>
<p>The guys in the <a href="http://www.codeplex.com/IronPython">IronPython</a> world have a bunch of samples that were created by <a href="http://www.voidspace.org.uk/ironpython">Michael Foord</a>. I thought it might be interesting to port those samples to <a href="http://www.ironruby.net">IronRuby</a>.</p>
<p><a title="http://www.voidspace.org.uk/ironpython/silverlight/index.shtml" href="http://www.voidspace.org.uk/ironpython/silverlight/index.shtml">http://www.voidspace.org.uk/ironpython/silverlight/index.shtml</a></p>
<p>Over the next couple of days I&#8217;ll post those on this site. Tomorrow we&#8217;ll start with the basics of using <a href="http://silverlight.net">silverlight</a> and <a href="http://www.ironruby.net">IronRuby</a> to write applications.</p>
<p>&#160;</p>
<div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:0ed87ce9-6062-4fd4-a125-5d8afe4ce9b2" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati Tags: <a href="http://technorati.com/tags/ironpython" rel="tag">ironpython</a>,<a href="http://technorati.com/tags/ironruby" rel="tag">ironruby</a>,<a href="http://technorati.com/tags/silverlight" rel="tag">silverlight</a></div>
]]></content:encoded>
			<wfw:commentRss>http://rubydoes.net/2008/04/12/getting-started-with-silverlight-and-ironruby/feed/</wfw:commentRss>
		<feedburner:origLink>http://rubydoes.net/2008/04/12/getting-started-with-silverlight-and-ironruby/</feedburner:origLink></item>
	</channel>
</rss>
