dsp_099
dsp_099

Reputation: 6121

Is there a way to use Ruby and WPF?

I found "Ruby in Steel," but that (I think) only works with visual studio 2008 and doesn't support the new WPF/XAML.

Is there such a thing or are these pipe dreams? :)

Upvotes: 4

Views: 833

Answers (2)

Vasiliy Ermolovich
Vasiliy Ermolovich

Reputation: 24617

Look at DiskUse project in your IronRuby 1.1\Samples\ directory. It uses WPF and XAML. For example, it's how they load xaml:

module DialogUtil
  def load_xaml(filename)
    f = IO::FileStream.new(filename, IO::FileMode.Open, IO::FileAccess.Read)
    begin
      element = Markup::XamlReader::Load(f)
    ensure
      f.close
    end
    element
  end

  module_function :load_xaml
end 

and then using it:

@window = DialogUtil.load_xaml("mainWindow.xaml")
@window.closing { @app.shutdown }
@windowTitle = @window.title
...
@window.show

And yes, it works OK with VS2010 - http://ironruby.codeplex.com/

Upvotes: 5

svick
svick

Reputation: 244767

The main installer for IronRuby does support VS 2010. It also supports Silverlight, but it doesn't seem to support WPF.

Maybe it would be possible to use it by manually editing the project file and writing the boilerplate code that VS usually generates yourself.

EDIT: After some testing, it seems you can use WPF from Iron Ruby without any problems, but you can't use XAML directly.

Upvotes: 0

Related Questions