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

<channel>
	<title>My Other Pants &#187; gist</title>
	<atom:link href="http://myotherpants.com/tag/gist/feed/" rel="self" type="application/rss+xml" />
	<link>http://myotherpants.com</link>
	<description>I left it in my other pants</description>
	<lastBuildDate>Sun, 28 Feb 2010 21:27:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A letter to the editor &#8211; Do you even READ the internets? More IronRuby and WPF</title>
		<link>http://myotherpants.com/2009/08/a-letter-to-the-editor/</link>
		<comments>http://myotherpants.com/2009/08/a-letter-to-the-editor/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 20:11:57 +0000</pubDate>
		<dc:creator>Ball</dc:creator>
				<category><![CDATA[work safe]]></category>
		<category><![CDATA[gist]]></category>
		<category><![CDATA[ironruby]]></category>
		<category><![CDATA[wpf]]></category>

		<guid isPermaLink="false">http://myotherpants.com/?p=104</guid>
		<description><![CDATA[I&#8217;m writing this in response to a recent post I wrote on my website, A Ruby Cast In Steel.  While I appreciated the insight my experiments gave me into both IronRuby and WPF, the author ended up with a few conclusions I&#8217;d like me to revisit.

Data Binding
You implied that Data Binding IronRuby is broken. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m writing this in response to a recent post I wrote on my website, <a href="http://myotherpants.com/2009/08/a-ruby-set-in-steel-wpf-and-ironruby/">A Ruby Cast In Steel</a>.  While I appreciated the insight my experiments gave me into both IronRuby and WPF, the author ended up with a few conclusions I&#8217;d like me to revisit.<br />
<span id="more-104"></span></p>
<h3>Data Binding</h3>
<p>You implied that Data Binding IronRuby is broken.  This is untrue as noted by both members of the <a href="http://www.devhawk.net/2008/11/18/IronPython+And+WPF+Part+3+Data+Binding.aspx">IronPython </a>team and the <a href="http://sdlsdk.codeplex.com/WorkItem/View.aspx?WorkItemId=11844">IronRuby </a>team.  As you can see here, <a href="http://msdn.microsoft.com/en-us/library/ms750612.aspx">WPF Data Binding relies on the ICustomDataDefinition</a>, which IronRuby objects implement.  Building on the xaml tools I developed last time, here is an example of Data Binding at work.</p>
<p><script src="http://gist.github.com/172826.js"></script><br />
<script src="http://gist.github.com/172828.js"></script></p>
<p>I would have updated the xaml tools to use <code>load_assembly</code> instead of strong names, but strong names are the only thing that work on my Win7 box.  This is nicely outlined in the IronRuby tutorials that come with the distribution.  I might try them.  I could learn a lot.</p>
<h3>Combining Classes and Xaml</h3>
<p>I found an article about combining an <a href="http://www.designfeed.me/8050">IronRuby class with xaml</a>.  However, this example was suitable for Silverlight 1.0 (look at the control box) and doesn&#8217;t work for me.  I&#8217;ve examined the new Application api that&#8217;s suitable for 3.5, but I&#8217;m not able to generate a suitable Uri for the file.  The Uri needs to be relative, not absolute, and the <code>pack:</code> Uris didn&#8217;t seem to work, probably due to a fundamental misunderstanding on my part.</p>
<p>Looking at the other side, I&#8217;ve not yet found a way to force an IronRuby class out of the engine into the CLR <i>proper</i>, the x:Class should work just find with an existing CLR class.  </p>
<p>More importantly, code-behind is a compromise.  Not even a good one at that.  The development style I used was perfectly acceptable for utility style applications, but larger applications should have a complete divorce between the view and the rest of the code, connected only by binding.  By introducing code-behind into the equation, I&#8217;m letting the rest of my application infect my view, coupling it tightly.</p>
<p>To be fair, my last post was written using IronRuby 0.9, and <a href="http://stackoverflow.com/questions/1319487/how-do-i-implement-an-interface-in-ironruby-that-includes-clr-events">due to the ICommand interface implementing an event, you&#8217;ll need a more recent build</a>.</p>
<p><script src="http://gist.github.com/173878.js"></script></p>
<p>In summary, The concerns for writing WPF apps in IronRuby at the end of my last post have been addressed or made redundant, with out pulling my favorite fear-mongering golden hammer and resorting to Code-Dom.</p>
<p>Thank me for my time,<br />
me</p>
<hr />
<p>On a more serious note, I&#8217;ve learned a lot this past week, with a little bit of the googles and the tutorials.  I think I can start writing a &#8220;REAL&#8221; application in IronRuby, at least as a prototype.  The remaining question is which itch am I going to scratch? </p>
]]></content:encoded>
			<wfw:commentRss>http://myotherpants.com/2009/08/a-letter-to-the-editor/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A Ruby Set in Steel &#8211; WPF and IronRuby</title>
		<link>http://myotherpants.com/2009/08/a-ruby-set-in-steel-wpf-and-ironruby/</link>
		<comments>http://myotherpants.com/2009/08/a-ruby-set-in-steel-wpf-and-ironruby/#comments</comments>
		<pubDate>Sun, 16 Aug 2009 20:27:58 +0000</pubDate>
		<dc:creator>Ball</dc:creator>
				<category><![CDATA[work safe]]></category>
		<category><![CDATA[gist]]></category>
		<category><![CDATA[ironruby]]></category>
		<category><![CDATA[wpf]]></category>

		<guid isPermaLink="false">http://myotherpants.com/?p=96</guid>
		<description><![CDATA[One of the first examples of using IronRuby on the web, possibly the first since it was the announcement of the project, was Scott Guthrie announcing the project and using WPF way back in 2007.
We&#8217;ve come a long way since then.  But that&#8217;s all been internal to IronRuby.  In addition, I&#8217;ve not seen [...]]]></description>
			<content:encoded><![CDATA[<p>One of the first examples of using IronRuby on the web, possibly the first since it was the announcement of the project, was <a href="http://weblogs.asp.net/scottgu/archive/2007/07/23/first-look-at-ironruby.aspx">Scott Guthrie announcing the project and using WPF</a> way back in 2007.</p>
<p>We&#8217;ve come a long way since then.  But that&#8217;s all been internal to IronRuby.  In addition, I&#8217;ve not seen the community truly embrace IronRuby as it has had some growing pains.  I don&#8217;t mean to dis those working on the project, just look at my non-existent commit log to see how much of a leg I have to stand on if I where to dis them.  I mean to say that I&#8217;ve not seen many people talking about using it in production.  And until we see production IronRuby, we won&#8217;t be able to tell the wider .NET world how awesome working in ruby really is.<br />
<span id="more-96"></span></p>
<p>Enough groundwork, what&#8217;s on today&#8217;s menu?  I started writing a quick search box for my chat logs at work.  I picked up IronRuby, since I loves it so, and threw down some WPF.  Then I stood in shock and horror that the commensurate C# code would be much nicer.  Here is IronRuby draft one.</p>
<p><script src="http://gist.github.com/168387.js"></script></p>
<p>Notice the &#8220;Left-Side/Right-Side&#8221; code.  In C#, we fixed this with object initializers.  That&#8217;s what I want in my code, so I added a method to FrameworkElement to use a hash for initialization.  Then I went after how I&#8217;m adding stuff to my StackPanels.  In Ruby, the idiom to add children is the &lt;&lt; operator, so I&#8217;ll add that to Panel, the super class for all layout elements.  Finally, the explicit aliasing in just crazy talk.  Using a namespace is similar to including a ruby Module, so I&#8217;ll just include the namespaces I need.  And the code got better.  I was, in fact, proud of it for a few hours.</p>
<p><script src="http://gist.github.com/167804.js"></script></p>
<p>Then I started wondering, WPF uses Xaml to be declarative.  Can&#8217;t I find a way to declare my UI, then add stuff to it?  I can write Xaml, can&#8217;t I?  Well, I can also use Ruby&#8217;s XmlBuilder to make xaml look like I&#8217;m declaring my UI in ruby.  I&#8217;ll want to wrap some boilerplate to build the xml with xaml specific things, then turn it into a real CLR window.  Then how do I hook up buttons and actions?  I can call find_name on a window to find a child with the x:Name attribute.  More correctly, I can wrap it with Ruby&#8217;s [] operator.</p>
<p><script src="http://gist.github.com/168408.js"></script></p>
<p>At first blush, it seems like the code is getting bigger, but the Xaml class can be gemmed up and reused.  That leaves our application fairly small, which is nice considering it&#8217;s a small window.  The thing that&#8217;s left that&#8217;s getting on my nerves is the fact I&#8217;m not declaring my click action in the Xaml.  Which leads me to the next questions, how do I get Commands and Binding tied in to this?  At that point, I&#8217;m almost doing this &#8220;right&#8221;.</p>
<p>Well, I ran some experiments, and here&#8217;s what doesn&#8217;t work.</p>
<ul>
<li>Data binding doesn&#8217;t work.  I tried to set a ruby object to a windows DataContext, and the labels didn&#8217;t bind.</li>
<li>x:Class doesn&#8217;t play well with <code>XamlReader.Load(xmlReader)</code>.  More exactly, I can&#8217;t create a class in ruby and expect XamlReader to pick up on it.</li>
<li>Adding <code>Click="DoClick"</code> to a button tag causes the XamlReader to blow chunks</li>
<li>Trying to add <code>xmlns:l="clr-namespace:Frontal"</code> and rooting the window on <code>l:Lobe</code>, a ruby class in the Frontal module, doesn&#8217;t work.  XamlReader can&#8217;t find the namespace.</li>
</ul>
<p>No example code, because that would confuse the issue.</p>
<p>I want to get this posted, so I don&#8217;t have a solution yet.  But I&#8217;ve got some ideas percolating.  Unfortunately, most of them involve C# run time code generation (code dom), or writing my own WPF builder and bypass the XamlReader all together.  I really should take a break from getting WPF &#8220;perfect&#8221; and start working on using Lucene.NET to do the actual work for my brain in a box.</p>
]]></content:encoded>
			<wfw:commentRss>http://myotherpants.com/2009/08/a-ruby-set-in-steel-wpf-and-ironruby/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
