WPF 表单 "does not exist in namespace" 错误...虽然如此! (使用 GreatMaps)

WPF form "does not exist in namespace" error...it does though! (using GreatMaps)

我在一个项目中尝试使用自定义控件。我创建了一个 class 用于它,在 class 中它需要 .DLL。这是 class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GMap.NET.WindowsPresentation;

namespace HackathonBaseWPF
{
    class MapControl : GMapControl
    {
    }
}

在我的 MainWindow.xaml 中,我将它用作组件之一,但它一直说 MapControl 不存在于命名空间中,即使在我为 mapControl 对象键入它时它自动完成为 MapControl .

<Controls:MetroWindow x:Class="HackathonBaseWPF.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
        Title="Base" 
        Height="895" 
        Width="1145"
        xmlns:src="clr-namespace:HackathonBaseWPF">
    <Grid Name="grid" Loaded="Grid_Loaded">

        <GroupBox Name="mapgroup"  Header="gmap" Margin="12,7,241,12" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch">
            <src:MapControl x:Name="mapControl" />
        </GroupBox>

    </Grid>
</Controls:MetroWindow>

有什么想法吗?我查看了所有与此类似的论坛帖子,但没有多少人使用带有 class(不是 .dll)的自定义控件。也许有一种方法可以绕过它并只使用 .dll(如果有帮助,我正在尝试集成 GreatMaps)

您已使用 "Controls" 作为命名空间名称来导入 Mapcontrol。

xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"

但是你曾经"src"使用MapControl。

  <GroupBox Name="mapgroup"  Header="gmap" Margin="12,7,241,12" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch">                      
<src:MapControl x:Name="mapControl" />
</GroupBox>

类似这样的代码

<GroupBox Name="mapgroup"  Header="gmap" Margin="12,7,241,12" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch">
        <Controls:MapControl x:Name="mapControl" />
    </GroupBox>