Dynamic Script Control

June 11th, 2008 casualjim Posted in xaml, IronPython, Silverlight, IronRuby 1 Comment »

Both Silverlight and WPF use XAML markup to describe their user interface.  As I’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’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. 

The DLR based languages don’t compile into static assemblies and this means that you can’t use those xml namespace definitons to reference your assemblies.  I wrote a fairly trivial control that acts like a hook for DLR based controls in the XAML tree.

You can check it out at codeplex.
http://codeplex.com/dynamicscriptcontrol

The idea behind this control is that you can "hook" your DLR based control into the visual tree by setting some properties.  You can set properties on the DLR based control by setting the Attributes property on the DynamicScriptControl

Let’s look at a quick example:

1. The ruby file defining a custom TextBox. But you can do whatever  you want in that ruby file of course.

dynamic_script_control_rubyscript

All this textbox does is preset it’s text property to "I’m prefilled"

2. The xaml for the window

dynamic_script_control_window_xaml 

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.
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’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.

3. The result

dynamic_script_control_window

Michael Foord the author of IronPython In Action will provide the python integration in this control.

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.  That is what makes it possible to support multiple scripting languages from the start. 

I’ve hosted the source code on google and you can find that at:

http://code.google.com/p/dynamic-script-control

AddThis Social Bookmark Button

Getting started with Silverlight and IronRuby

April 12th, 2008 casualjim Posted in IronPython, Silverlight, IronRuby 2 Comments »

This is my first post on this site and I hope there will be many more to come :) I’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 that want to get into IronRuby.

When the beta for Silverlight 2.0 was released it got support for IronRuby. I personally think that Silverlight and IronRuby is a winning team.  But when you come from normal web development or windows forms development it does have little bit of a learning curve because of XAML.
But once you get passed that learning curve it’s a pretty sweet technology to master :)

There are other people that have blogged about silverlight and IronRuby before, it might be a good idea to check them out as well.

The guys in the IronPython world have a bunch of samples that were created by Michael Foord. I thought it might be interesting to port those samples to IronRuby.

http://www.voidspace.org.uk/ironpython/silverlight/index.shtml

Over the next couple of days I’ll post those on this site. Tomorrow we’ll start with the basics of using silverlight and IronRuby to write applications.

 

AddThis Social Bookmark Button

Some recent podcasts

September 30th, 2007 Aaron Junod Posted in IronPython, Links, podcasts, IronRuby 3 Comments »

Earlier this week I listened to Scott Bellware on Rubiverse on moving to ruby, and his thoughts on IronRuby. He seems relatively skeptical on IronRuby with some very just reasoning. He does make one very important point with IronRuby though, it will only be as good as the community makes it. John Lam and team can only go so far within the confides of the MS campus, and none of the other Ruby implementations have been completed in a bubble, they have all benefited greatly from an active community. Isn’t that the name of the game with open source anyway?

In any case, the podcast is a great listen, and should hopefully get you motivated to become active with IronRuby, because we all want to see it succeed right? :)

Craig Murphy also just posted a podcast with interviews of Michael Foord and Dave Verwer named the men of ruby Iron (Thanks Mike Moore). It covers IronRuby, IronPython, and the DLR. I haven’t listened yet, but just subscribed to the feed.

AddThis Social Bookmark Button

Did you hear the pin drop?

August 15th, 2007 Aaron Junod Posted in IronPython, IronRuby No Comments »

I did, it’s been very quiet around here. It’s like the calm before the storm. In between reading Applying DDD and Beautiful Code I’ve been researching IronRuby, but really anxious for the next drop. Jon Lam posted yesterday about their last few weeks, and what they intend to include in the next drop, and man am I siked.

Ronan Geraghty also posts on using IronPython in ASP.net and the DLRConsole, the very cool dynamic console that lets you manipulate WPF elements in real time by typing in a commandline like interface. Very cool..

AddThis Social Bookmark Button