Question

First I just want to say I am new to WPF, so please excuse my ignorance...

I am creating a .Net plug-in for Rhino 4.0. With the plugin I am developing a UI using WPF.

The Rhino 4.0 CAD engine is an MFC/Win32 application. The plugin will execute after the application is run, and it creates the WPF Window and then "sucks" the MFC Window into it.

So my question is, does WPF look for an App.xaml file to get to Application level resources if the hosting application isn't a WPF app?

If not, what is the best way to store application level resources?

Thanks,

Jason

Was it helpful?

Solution

WPF projects will - by default - generate an entry point for your application. This entry point constructs and initializes your Application-derived class for you. If you need, you can always create your instance manually, and store application-level resources in it:

App app = new App();
app.InitializeComponent();
app.Run();

OTHER TIPS

App.xaml is used as a part of a partial class App : Application. If your application does not have a WPF based Application class, you can manually load dictionaries and merge with the application and create a main window and show it (access via static methods of Application class).

Code goes kind of like this.

var reader = new XamlReader();
var dictionary = reader.read("path to xaml file") as ResourceDictionary;
if (dictionary != null)
    Application.MergedDictionaries.Merge(dictionary);

var mainWindow = new MyMainWindow();
mainWindow.Show();

Have you tried storing your resources at what MSDN refers to as the 'theme level'?

Within a folder called "<root>\Themes" have a file called generic.xaml.

I haven't tried this for a project that wasn't a WPF application, but the approach might work for you.

my guess is it has to do with how does rhino run your plugin does it run it as a seperate process or does it just call some thing you have defined?

If it does call a function you defined then you could just put the code there that will start the window?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top