Skip to content

Instantly share code, notes, and snippets.

@jschementi
Created June 23, 2009 06:52
Show Gist options
  • Save jschementi/134401 to your computer and use it in GitHub Desktop.
Save jschementi/134401 to your computer and use it in GitHub Desktop.
# accessing named child elements
### normal
w.find_name("msg").text = "Hello"
### wpf.rb
w.msg.text = "Hello"
# showing, hiding, and collapsing elements
### normal
include System::Windows
e.visibility = Visibility.hidden
e.visibility = Visibility.collapsed
e.visibility = Visibility.visible
### wpf.rb
e.hide!
e.collapse!
e.visible
# loading XAML
xaml = "<TextBlock x:Name='foo' Text='Hello' />"
### normal
obj = XamlReader.load(
XmlReader.create(
StringReader.new(xaml.to_clr_string)))
obj.find_name('foo').text += "Jimmy"
### wpf.rb
XamlReader.load(xaml) do |obj|
obj.foo.text += "Jimmy"
end
# FlowDocument
### normal
paragraph = System::Windows::Documents::Paragraph.new
paragraph.inlines.add(System::Windows::Documents::Run.new(bunch_of_text))
rich_text_block.document.blocks.add paragraph
### wpf.rb
rich_text_block << bunch_of_text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment