Search code examples
wpfwindowsxamlmapspresentation

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


I have a project where I am trying to use a custom control. I have created a class to use for it and in the class it requires the .DLL. Here is the class:

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

namespace HackathonBaseWPF
{
    class MapControl : GMapControl
    {
    }
}

and in my MainWindow.xaml I use it as one of the components but it keeps saying that MapControl does not exist in the namespace, even though it auto completed to MapControl when I was typing it for the mapControl object.

<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>

Any ideas? I have looked at all the forum posts similar to this but not many are using custom controls with a class (not a .dll). Maybe there is a way to bypass this and just use the .dll (I am trying to integrate GreatMaps if that helps)


Solution

  • you have used "Controls" as namespace name to import Mapcontrol.

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

    But you used "src" to use MapControl.

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

    Insted of this code like

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