首页 > 解决方案 > 如何在没有 WPF 按钮单击的情况下更新线框?

问题描述

我正在开发一个 Windows 窗体应用程序,其中 WPF 用户控件嵌入在 WF 中。如果我添加一个按钮并执行我的userControl.DrawWireFrameCube();My ViewPort3D 得到更新。我正在使用 Helix 3D 工具包。但是如果我从我的 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,我想保持这种状态。任何想法这里有什么问题?

PS我喜欢没有解释的反对票:)

标签: c#wpfwinforms3dhelix-3d-toolkit

解决方案


推荐阅读