Silverlight.rb

I would like to use the Wpf.build method contained in the silverlight.rb
file. Currently I can only find this file in the photoviewer app from
2008 for what looks like Silverlight 2. Is there an updated version of
this file? I noticed it isn’t contained in the 1.0RC1 download.

Thanks,
Randall

Silverlight.rb has actually been embedded in the
Microsoft.Scripting.Silverlight.dll (as init.rb) and is loaded
automatically, but I didn’t include Wpf.build, so the version you have
in the photoviewer app is the latest, so use at your own risk. It could
possibly be added for the final release, or put in an external helper
file. Let me know if it works for you currently.

~Jimmy

I ended up just taking the idea and making my own version.

class Wpf
def self.create(t,args={},&b)
# create an instance of the class
obj = t.new

      # assign all the args
      args.each_pair do |k,v|
          obj.send("#{k.to_s}=",v)
      end

      # define the add method if it doesn't have one
      if !(obj.respond_to? :add) && (obj.respond_to? :children)
          obj.instance_eval('def add(t,args={},&b); obj = 

Wpf.create(t,args,&b); self.children.add(obj); obj; end;’)
end

      # call the create method if there is one
      if obj.respond_to? :create
          obj.create
      end

      # execute the block against the instance
      obj.instance_eval(&b)
      obj
  end

end

Not as complex as the other, so I might be missing something. So far
this has worked great and I added ability to have a create method so if
you are constructing a class that inherits from a control you could do
some initialization before the block is executed.

Thanks,
Randall

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs