Wednesday, August 26, 2009

Resource Stream in C# .Net

Steps on how to add and retrieve an instance of your resource file:

1. Right click the file, select Properties.

2. Under Build Action, select Embedded Resource as shown below



3. Syntax in retrieving an instance:

FrameworkElement content = new FrameworkElement();
Assembly asm = Assembly.GetExecutingAssembly();
Stream sre = asm.GetManifestResourceStream("namespace here);
content = XamlReader.Load(sre) as FrameworkElement;

No comments:

Post a Comment

About Me

My photo
simple and straight forward