c# - How to show a WinForms Window in a WPF Grid or Viewbox -
in xml file:
<viewbox name="viewbox1"></viewbox> in c# code-behind:
windowformclass window1 = new windowformclass(); // winforms object, not wpf viewbox1.child = window1; when assign window1 viewbox1 shows error cannot convert window form system.window.elementui
what's right way that?
you should use wpf's interop host control winforms called windowsformshost.
code below extracted , adapted msdn
// create interop host control. system.windows.forms.integration.windowsformshost host = new system.windows.forms.integration.windowsformshost(); // create control. windowformclass window1 = new windowformclass(); // assign control host control's child. host.child = window1; // set interop host control viewbox child. viewbox1.child = host; a user reported problem hosting windowsformhost inside viewbox. should check out in case have problems too.
as (apparently) newcomer, i'd give little tip: there plenty of resources on subject on both msdn , found through simple search on favourite search engine.
next time, try find solution before posting question, keep best answers on topic , save moderators work of closing questions duplicates.
more on that, check help so
Comments
Post a Comment