I'm writing a SolidWorks addin, where I can host WPF only within an Winforms Elementhost. Now I want to use a Flyout from Mahapps.Metro, which depens on being hosted in a MetroWindow. Is there any way I can use the Flyout from within a WPF Usercontrol? I'm using .NET 4.6.2, Mahapps.Metro 1.6 and SolidWorks 2018.
-
Actually a `UserControl` can absolutely host a `Flyout` on its own. The real problem is that the `Flyout`'s nice round button with an arrow sign inside does not carry over too well to the `ElementHost` : all you get is a square button with some garbage inside. But otherwise it works fine as far as opening and closing the `Flyout`. – jsanalytics Mar 05 '18 at 22:17
-
According to this [link](https://github.com/MahApps/MahApps.Metro/issues/1620) the flyout depends on being hosted in a metrowindow? – Ksdmg Mar 06 '18 at 10:00
-
Perhaps they "fixed" it since 2014? Just give it a try... [Here's what i got](https://imgur.com/XO7ZL0E). Notice the ugly, messed-up button. But it seems functionally operational, at least for containing a simple `TextBlock`. – jsanalytics Mar 06 '18 at 12:41
2 Answers
Looks like the Information I found here and here is obsolete. I just installed the NuGet Packages Mahapps.Metro and Mahapps.Metro.Iconpacks and everything is working as expected.
If someone is trying to do it in a SolidWorks Addin too, make sure to manually load a new version of System.Windows.Interactivity, because Solid is loading an old version from the application base directory, which is not compatible with Mahapps.Metro!

- 397
- 5
- 15
Be very careful when you are working with .NET add-ins for solidworks. If your application uses some third-party UI lib, you need to copy those referenced assemblies to the host application (sldworks.exe) directory. For some reason, the domain application is that of hosting exe and not the dll. CLR will look for references in the sldworks.exe's directory and it doesn't find, the application throw some nasty exception that will crash your SOLIDWORKS.

- 1,884
- 4
- 28
- 51
-
You don't need to copy the dll's when you are using an IL weaver like Costura.Fody – Ksdmg Mar 18 '18 at 08:38
-
-
1The IL weaver embeds all referenced libraries that have CopyLocal set to true. You can find all informations about this on the costura GitHub page! – Ksdmg Mar 20 '18 at 12:30
-