Search code examples
wpfvisual-studio-2010user-interfaceironruby

Building IronRuby WPF GUIs


This may be a silly question but I was under the impression that it was possible to use IronRuby and MS Visual Studio 2010 together to sort of build interfaces\edit XAML in one window and code ruby in the other?

Is this only possible to do with C#, Basic and C++ ?

I've browsed SO and seen some IronRuby snippets like this one:

button1.click do |sender, args|
    MessageBox.show("Hello World!")
end

So it stands to reason you can create GUIs somehow, but is the visual gui creator not available for ironruby?


Solution

  • In order to build GUIs you should use XAML with WPF. You can create XAML with the editor in Visual Studio. Running a XAML file is possible with:

    require "PresentationFramework"
    include System::Windows
    include System::Windows::Markup
    
    xaml = File.Open('d:/app/window1/xaml', "r").read
    @root = System::Windows::Markup::XamlReader.parse(xaml)
    
    app = System::Windows::Application.new
    app.run @root
    

    Please refer to IronRuby Unleashed for more information