[Ironruby-core] Reading files in Dynamic Silverlight
jomes at microsoft.com
Sun Apr 6 17:15:48 EDT 2008
Ivan Porto Carrero:
> I can't work out how I can read external xaml files from Silverlight
> with IronRuby.
> I've tried to use System::IO::File and StreamReader but both give me a
> How would I accomplish reading a xaml file in the xap with IronRuby
> and Silverlight.
> I would like to create a user control and load that into my main app.
> System.IO.Stream s = this.GetType().Assembly.GetManifestResourceStream("story_details_view.xaml")
> _root = this.InitializeFromXaml(new
> System.IO.StreamReader(s).ReadToEnd()) as UserControl;
I'm not sure why the above C# code wouldn't "just work". Which method call throws MethodAccessException?
The only thing that looks odd is the GetManifestResourceStream. The way I've done it is:
s = System.Windows.Application.Current.GetResourceStream(new Uri("story_details_view.xaml", UriKind.Relative));
> I would also like to try to read an external xaml file for skinning
> Is that possible at this moment?
Sure, just use the normal Silverlight downloading APIs. Check out the WebClient and HttpWebRequest classes.
More information about the Ironruby-core