tags:

views:

614

answers:

2

I changed the build action of my App.xaml to "Page" so I could handle a splash screen and make sure my application run as a single instance only (having my own entry point). It works fine in run-time but in design-time the application cannot see the my resources anymore. Resources are in separate xaml files located in the same project. How can I make my app see the resources in design-time again?

Thanks

+2  A: 

If I understand you correct, you're loading Application-wide resources in the app.xaml? In this case you can do like this:


App app = new App();
//Get assembly name is your own method
string assemblyName = GetAssemblyName(Assembly.GetExecutingAssembly());

Uri resourceLocater = new Uri("/" + assemblyName + ";component/app.xaml", UriKind.Relative);
System.Windows.Application.LoadComponent(app, resourceLocater);
MainWindow mainWindow = new MainWindow();
app.Run(mainWindow);

Then your resources will be loaded

/Daniel

Daniel Enetoft
A: 

Make sure you are calling InitializeComponent() as the first line of your application's constructor:

public App()
{
    // This is the method generated by VisualStudio that initializes
    // the application from associated XAML file
    InitializeComponent();

    // Do everything else
}
Bojan Resnik