> -----Original Message-----
> From: ironruby-core-boun...@rubyforge.org 
> Jimmy Schementi
> Sent: Monday, November 16, 2009 5:32 AM
> 
> # This loads "foo.xaml" into the "canvas" variable include 
> System include System::Windows include 
> System::Windows::Controls canvas = Canvas.new 
> Application.load_component canvas, Uri.new("foo.xaml", 
> UriKind.relative)

I was looking for ways to load XAML to a custom class from a file at
runtime in the way described above. I have load_component.rb:

  require 'PresentationFramework, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'
  require 'PresentationCore, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'
  require 'WindowsBase, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'

  include System 
  include System::Windows 
  include System::Windows::Controls 

  canvas = Canvas.new 
  Application.load_component(canvas, Uri.new("foo.xaml",
UriKind.relative) )

I have my foo.xaml file in the same location as the ruby script above.
When I run the script with "ir load_component.rb" I get error:

PresentationFramework:0:in `GetStreamCore': Cannot locate resource
'foo.xaml'. (IOError)
        from WindowsBase:0:in `GetStream'
        from WindowsBase:0:in `GetStream'
        from PresentationFramework:0:in `LoadComponent'
        from loadcomponent.rb:0

Where should I put the foo.xaml for the script above to find it? Only
examples I found from Application.LoadComponent from MSDN were using
relative URI:s referring to XAML-files embedded in some assembly. I want
to load a XAML-file on a disk however. XamlReader.Load is not enough for
me since I need to have custom classes created with the xaml:class="..."
attribute.

Robert Brotherus
_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core

Reply via email to