I have a small problem with my wpf plugin. It has to do with the display of the wpf window when trying to use styles.
I have recreated the problem here, in case you want to look at it in depth.
The wpf window is opened with test.testCommand and it works fine until I try to apply a style to the wpf window (WpfApplication1.MainWindow.xaml):
Style="{StaticResource CustomWindow}" naturally links to the App.xaml file but it crashes Rhino when executed this way. If Style="{StaticResource CustomWindow}" is omitted everything works again.
Keep in mind that your plug-in is DLL, not an application-level object.
To share style resources in your DLL, you will first need to create a style dictionary. Then you will need to merge the dictionary with your window resources in you xaml file.
I don’t have an example that I can point you to, but you should be able to find plenty of resources on the web.
I have two projects in my solution. Project1 is the Rhino plugin with a command which opens Project2 as shown below. Project2 is a wpf application. Is that maybe the problem or can it work like this?
using WpfApplication1;
namespace test
{
[System.Runtime.InteropServices.Guid("efe72d01-5dfe-428e-afe9-fd82d5dbb2df")]
public class testCommand : Command
{
// Removed code for clarity
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
System.Windows.Window my = new WpfApplication1.MainWindow();
new System.Windows.Interop.WindowInteropHelper(my).Owner = Rhino.RhinoApp.MainWindowHandle();
my.Show();
return Result.Success;
}
}
}
Exchanging “MyAssembly” to the Assembly name of the plugin, because the plugin’s assembly is not the entry assembly, and WPF’s default resource lookup failed for me