我正在开发Windows窗体应用程序,该窗体具有嵌入WF中的WPF用户控件。如果我添加一个按钮并执行userControl.DrawWireFrameCube();
,我的ViewPort3D将得到更新。我正在使用Helix 3D Toolkit。但是,如果我从MainWindowForm类中调用方法,则该方法将不会执行且UI也不会更新,而只有userControl.DrawWireFrameCube();
无法正常工作。另一种userControl.Draw3DObject(insertionPoint, points, color);
方法工作正常。
private void VisualizePart(int index)
{
InsertionPoint insertionPoint = new InsertionPoint
{
X = _duplicatedListParts[index].INFO1,
Y = _duplicatedListParts[index].INFO2,
Z = _duplicatedListParts[index].INFO3
};
DetailSize points = new DetailSize
{
Length = _duplicatedListParts[index].LENGTH,
Width = _duplicatedListParts[index].WIDTH,
Thickness = _duplicatedListParts[index].THICKNESS
};
userControl.Dispatcher.Invoke(() =>
{
System.Windows.Media.Color color = System.Windows.Media.Color.FromRgb(255, 90, 0);
userControl.Draw3DObject(insertionPoint, points, color);
userControl.DrawWireFrameCube();
});
}
不同之处在于,我在Draw3DObject()
中向Model3DGroup
添加了项目,而在DrawWireFrameCube()
中向MyViewPort3D
添加了项目。我没有使用XAML,但我想保持这种状态。
任何想法在这里出什么问题吗?
P.S我喜欢没有解释的否定投票:)