4
votes

I'm getting "The name xxx does not exist in yyy" all the time. I don't understand why, i think i tried all possible combinations.

All of my cs file, including main window are in "Web_Media_Seeker_WPF" namespace

Converters.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace Web_Media_Seeker_WPF.WPFConverters
{
    public class BoolToValueConverter<T> : IValueConverter
    {
        public T FalseValue { get; set; }
        public T TrueValue { get; set; }

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
                return FalseValue;
            else
                return (bool)value ? TrueValue : FalseValue;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return value != null ? value.Equals(TrueValue) : false;
        }
    }

    public class BoolToObjectConverter : BoolToValueConverter<Object> { }
    public class BoolToStringConverter : BoolToValueConverter<String> { }
    public class BoolToBrushConverter : BoolToValueConverter<System.Windows.Media.Brush> { }
    public class BoolToVisibilityConverter : BoolToValueConverter<System.Windows.Visibility> { }
    public class BoolToColorConverter : BoolToValueConverter<System.Windows.Media.Color> { }
    public class BoolToImageSourceConverter : BoolToValueConverter<System.Windows.Media.ImageSource> { }
    public class BootToBoolConverter : BoolToValueConverter<bool> { }

        public class AddValueConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            object result = value;
            int Value;

            if (value != null && targetType == typeof(Int32) &&
                int.TryParse((string)parameter,
                System.Globalization.NumberStyles.Integer, culture, out Value))
            {
                result = (int)value + (int)Value;
            }

            return result;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}

MainWindow.xaml

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namesapce:Web_Media_Seeker_WPF.WPFConverters"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        x:Class="Web_Media_Seeker_WPF.MainWindow"
        Title="Web Media Seeker"
        Height="563"
        Width="836">
  <Window.Resources>
    <local:BoolToImageSourceConverter x:Key="BoolToWorkImageSource"
                                      TrueValue="Images/work.png"
                                      FalseValue="Images/idle.png" />
    <local:BootToBoolConverter x:Key="InvertBool"
                               TrueValue="False"
                               FalseValue="True" />
    <local:BoolToStringConverter x:Key="WorkTooltip"
                                 TrueValue="Working..."
                                 FalseValue="Idle" />
  </Window.Resources>
and stuff...

Errors i have:

The name "BoolToImageSourceConverter" does not exist in the namespace "clr-namesapce:Web_Media_Seeker_WPF.WPFValuesConverters".

The name "BoolToStringConverter" does not exist in the namespace "clr-namesapce:Web_Media_Seeker_WPF.WPFValuesConverters".

The name "BootToBoolConverter" does not exist in the namespace "clr-namesapce:Web_Media_Seeker_WPF.WPFValuesConverters".

The tag 'BoolToImageSourceConverter' does not exist in XML namespace 'clr-namesapce:Web_Media_Seeker_WPF.WPFValuesConverters'.

The type 'local:BoolToImageSourceConverter' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.

The type 'local:BoolToStringConverter' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.

The type 'local:BootToBoolConverter' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.

2

2 Answers

7
votes

There's an error in your namespace declaration:

xmlns:local="clr-namesapce:Web_Media_Seeker_WPF.WPFConverters"

should be

xmlns:local="clr-namespace:Web_Media_Seeker_WPF.WPFConverters"

You put namesapce instead of namespace

0
votes

I had this problem without the typo. The problem wasn't directly with the XAML, or at least not completely. The original developer had named the Window tag with the same name as the code-behind class name, and that seems to be prohibited now. That was the only issue with the XAML. Everything else had to do with overlaps in the WPF and Windows.System.Data libraries that caused IValueConverter (in the System.Windows.Data namespace) to go unrecognized. I first searched through the Object Browser for all libraries that had the IValueConverter interface. Of those, two were in my project, one as an afterthought because I thought I'd need it to replace elements of the WPF toolkit 3.5, which I removed. I deleted the one I thought I could do without, and that removed the issue. It's sort of an 'ambiguous reference' error but it doesn't come up that way.