我现在正在做 Autodesk Navisworks 的二次开发。xaml 看起来像这样:
<Window x:Class="SCA.EmergencySystem.Gui.MainFrame.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns:nc="clr-namespace:SCA.EmergencySystem.NavisInterface.NavisControl;assembly=SCA.EmergencySystem.NavisInterface.NavisControl"
Height="577.33" Width="879.502" Closed="on_Window_Closed" ShowInTaskbar="False" Title="EmergencySystem">
<DockPanel>
<WindowsFormsHost>
<nc:NavisViewControl x:Uid="viewControl" x:Name="viewControl" Dock="Fill"/>
</WindowsFormsHost>
</DockPanel>
</Window>
似乎视觉工作室成功地识别了这一行:
xmlns:nc="clr-命名空间:SCA.EmergencySystem.NavisInterface.NavisControl;assembly=SCA.EmergencySystem.NavisInterface.NavisControl"
所以我认为命名空间和程序集都可以
但是,XAML 未能找到已在加载到 WPF 项目的 NavisControl.DLL 中定义的控件的名称。NavisViewControl
那是我开发的System.Windows.Forms.Control
, Autodesk.Navisworks.Api.Controls
也是我开发的。nc:NavisViewControl
不被识别。
NavisViewControl 的代码很简单:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Autodesk.Navisworks.Api.Controls;
namespace SCA.EmergencySystem.NavisInterface.NavisControl
{
public class NavisViewControl : ViewControl
{
}
}