Wednesday, January 23, 2013

Resource File Add From Other Project


I am keen to interest to develop a Silverlight application with mvvm pattern but have some drawback to have to implement.
To have to develop mvvm pattern application i have needed a resource file add into my Silverlight project from another project.

You may have understood my problem. Here i am discussing solution of my problem with appropriate source code step by step.

First Step:
                Open your Silverlight project
Second Step:
                Open the App.xaml.cs file
Third Step:
                Copy the source code
                ResourceDictionary p = new ResourceDictionary();
                p.Source = new Uri("/AnotherProject;component/Themes/generic.xaml", UriKind.Relative);
               this.Resources.MergedDictionaries.Add(p);
Fourth Step:
                Paste the source code into app constructor that like as
         public App()
        {
            this.Startup += this.Application_Startup;
            this.Exit += this.Application_Exit;
            this.UnhandledException += this.Application_UnhandledException;

            InitializeComponent();
            ResourceDictionary p = new ResourceDictionary();
            p.Source = new Uri("/AnotherProject;component/Themes/generic.xaml", UriKind.Relative);
            this.Resources.MergedDictionaries.Add(p);
        }

No comments:

Post a Comment