[英]hosting WPF inside Windows Form giving issues - C#
I've created a .DLL in WPF. 我已经在WPF中创建了一个.DLL。 To use it in existing Windows Forms application I use
ElementHost
. 要在现有Windows窗体应用程序中使用它,我使用
ElementHost
。
ElementHost eleHOst = new ElementHost();
UserWarps userWarps = new UserWarps();
eleHOst.Child = userWarps;
eleHOst.Dock = DockStyle.Fill;
UserWarps
is in WPF .DLL
which has been add-referenced. UserWarps
位于已添加引用的WPF .DLL
中。 Now the file does lot of 3D manipulations. 现在,该文件执行了许多3D操作。 I'm also using
Petzold.Media3D
for 3D lines
for wireframe modelling. 我还将
Petzold.Media3D
用于3D lines
以进行线框建模。 Everything's working fine except that WireLines
of Petzold.Media3D
is not drawing any lines. 除了
WireLines
的Petzold.Media3D
不会绘制任何线外, WireLines
所有东西都工作正常。 If I reference the DLL from other WPF
applications everything's fine, but hosting the UserControl of wpf
in windows forms eliminates the lines/wireframes. 如果我从其他
WPF
应用程序引用了DLL,那么一切都很好,但是在Windows窗体中托管wpf
的UserControl可以消除线条/线框。 Rest everything is perfect - MeshGeometry3D
, Models, Visuals, functionalities etc. 休息一切都是完美的
MeshGeometry3D
,模型,视觉效果,功能等。
Please suggest the way forward. 请提出前进的方向。 could any alternative to
ElementHost
work? 可以用
ElementHost
替代吗? If it does then what is it? 如果可以,那是什么?
Adding answer originally added by OP in question as I don't want this question to be closed just because of that.
添加最初由有问题的OP添加的答案,因为我不想因为这个原因而关闭此问题。
Petzold has mentioned here that hosting wpf in Windows forms causes the Wire frames to disappear. Petzold在这里提到以Windows形式托管wpf会导致Wire框架消失。 He also posts a work around which is very simple and worked perfectly:
他还发布了一项非常简单且完美的工作:
NOTE: For reasons discussed in paragraph 5, these Wire classes will not work when you're hosting 3D in Windows Forms, or when you're trying to print a 3D scene.
注意:出于第5段中讨论的原因,当您在Windows Forms中托管3D或尝试打印3D场景时,这些Wire类将不起作用。 To make it work, try replacing the static
OnRendering
method in WireBase with the following:要使其工作,请尝试使用以下方法替换WireBase中的静态
OnRendering
方法:static void OnRendering(object sender, EventArgs args) { foreach (WireBaseAndUltimateParent wirebaseAndParent in listWireBases) { WireBase wirebase = wirebaseAndParent.wirebase; wirebase.OnRendering(); } }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.