2

I'm currently having a problem with Visual Studio 2012.

I have a WPF project with a window, and I would like to put a personalized class in this window.

So I created a new C# class, CarteCanvas.cs :

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WPF
{
    public class CarteCanvas : Canvas
    {
        public CarteCanvas()
        {
        }
    }
}

And in MainWindow.xaml, I call it like that :

<Window x:Class="WPF.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:WPF"
        Title="Boris World" Height="600" Width="800">
    <Grid Name="mainGrid">
        <Grid.RowDefinitions>
            <RowDefinition Height="400*" />
            <RowDefinition Height="170*" />
        </Grid.RowDefinitions>
        <ScrollViewer HorizontalAlignment="Stretch" Grid.Row="0">
            <local:CarteCanvas />
        </ScrollViewer>
        <Rectangle Fill="#FFF4F4F5" HorizontalAlignment="Stretch" Grid.Row="1" Stroke="Black" />
    </Grid>

</Window>

But this isn't working. I have this error : The name "CarteCanvas" does not exist in the namespace "clr-namespace:WPF". And when I start writing local: , the autocompletion is showing CarteCanvas, as if it was well recognized...

I don't know if I am doing this properly, or if there are some things to do, but if you could help me, I would be very thankful !

hellimac
  • 251
  • 7
  • 13
  • Ignore the error for a moment and build your project without . Then, reinsert . ( The XAML editor sometimes seems to be unable to find or validate the type if it is not built into the assembly yet. Don't ask me why, this happens in my projects occasionally, too.) –  Dec 28 '13 at 14:41
  • possible duplicate of [The name does not exist in the namespace error in XAML](http://stackoverflow.com/questions/14665713/the-name-does-not-exist-in-the-namespace-error-in-xaml) – lightbricko Dec 28 '13 at 14:43
  • xaml seems correct to me, probably a rebuild is necessary. Error message should disappear when you rebuild the project. – Xilmiki Dec 28 '13 at 18:01

0 Answers0