Skip to content

Instantly share code, notes, and snippets.

@Ball
Created August 15, 2009 16:27
Show Gist options
  • Save Ball/168387 to your computer and use it in GitHub Desktop.
Save Ball/168387 to your computer and use it in GitHub Desktop.
A bad example of WPF and IronRuby
require 'PresentationCore'
require 'PresentationFramework'
Application = System::Windows::Application
HorizontalAlignment = System::Windows::HorizontalAlignment
SizeToContent = System::Windows::SizeToContent
Thickness = System::Windows::Thickness
Window = System::Windows::Window
Button = System::Windows::Controls::Button
Label = System::Windows::Controls::Label
ListBox = System::Windows::Controls::ListBox
Orientation = System::Windows::Controls::Orientation
StackPanel = System::Windows::Controls::StackPanel
TextBox = System::Windows::Controls::TextBox
window = Window.new
window.title = "Lef' Frontal Lobe"
window.size_to_content = SizeToContent.height
window.width = 450
stack = StackPanel.new
stack.margin = Thickness.new(15)
window.content = stack
search_ctl = StackPanel.new
search_ctl.orientation = Orientation.horizontal
stack.children.add search_ctl
search_box = TextBox.new
search_box.width = 380
search_ctl.children.add search_box
search_button = Button.new
search_button.content = "Go"
search_ctl.children.add search_button
results_label = Label.new
results_label.font_size = 24
results_label.content = "Results"
results_label.horizontal_alignment = HorizontalAlignment.center
results_label.margin = Thickness.new(5)
stack.children.add results_label
results_list = ListBox.new()
stack.children.add results_list
search_button.click do |sender, event|
results_list.items.clear
results_list.items.add search_box.text
end
Application.new.run(window)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment