Building IronRuby WPF GUIs

2020-04-28 06:21发布

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?

1条回答
祖国的老花朵
2楼-- · 2020-04-28 07:00

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

查看更多
登录 后发表回答